Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple regular expression

Status
Not open for further replies.

Kathy1

Programmer
Dec 21, 2000
39
0
0
US
Hi All.

I'm trying to create what I thought would be a simple search pattern using a Javascript regular expression. However, it just won't work, even though similar expressions I've coded in Perl work just fine.

Here is my code:

<INPUT TYPE=&quot;button&quot; NAME=&quot;Continue2&quot; VALUE=&quot;Continue&quot;
onclick=&quot;Javascript:document.areWeDone = verifyCustomer();
if (document.areWeDone == true)
{
re = /issued/i;
testit = re.search(&quot;issuedornot&quot;);
stopTheBlink (top.heading_frame.blinkMeNot.value)
document.entry.submit();
}&quot;;
STYLE=&quot;background-color:#004080; color: #FFEAD5&quot;></INPUT>

The lines I am having problems with in this code are:
re = /issued/i;
testit = re.search(&quot;issuedornot&quot;);


I'm getting a syntax error on testit = re.search(&quot;issuedornot&quot;);
I've tried this same line using re.exec in place of re.search, and it hasn't helped.

In a nutshell, I need code to look for the word 'issued' in a string of characters. Sounds so easy, but its been giving me fits today.

The constant 'issuedornot' will be replaced with a variable as soon as I can get the regular expression to work properly. The other sections of this code have been working properly for some time...I'm just adding some new stuff into it.

Any help on this would be greatly appreciated.

Thanks!

Kathy :cool:

 
Thank you iza.

Between changing that, and getting the double-quotes out of 'issuedornot' string, as Javascript doesn't like doublequotes within doublequotes, it is now working. Here is the working code for anyone who is interested in using regular expressions in a Javascript on a button.

<INPUT TYPE=&quot;button&quot; NAME=&quot;Continue2&quot; VALUE=&quot;Continue&quot;
onclick=&quot;Javascript1.2:
document.areWeDone = verifyCustomer();
if (document.areWeDone == true)
{
var re = /issued/i;
var keep_on = true;
var testit = re.test(myObjectArray[document.entry.CName.selectedIndex]);
if (testit == true)
{
keep_on = window.confirm ('The application you have selected has already been issued. \n Any changes you make cannot be sent to the company.');
}
if (keep_on == true)
{
stopTheBlink(top.heading_frame.blinkMeNot.value);
document.entry.submit();
}
}&quot;;
STYLE=&quot;background-color:#004080; color: #FFEAD5&quot;>
</INPUT>


Thanks again!

Kathy :-V
 
thank *you* kathy, for letting everyone know the solution :)
hopefully this little thread might help many people ;] !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top