...

View Full Version : Help with using regular expression



codefox
12-23-2003, 08:11 AM
I have never used regular expressions. I have an immediate requirement that requires use of regular expressions. I have a set of macros, say $F, $R, $T, and $#1 to $#9. I have a text box which could accept any set of alphabetes, numbers, and/or one or more of the above-mentioned macros.

I have a function where I validate the text box content. How do I specify that if a $ only certain characters could be allowed as the next character?



var fnameReg = "[^A-Za-z0-9_\$\+\-\.\#]";
var regex = new RegExp(fnameReg);

if (regex.test(oText.value)) {
alert ("Please Enter a valid File Name MatchString..!" +
"Your file name string can contain ONLY A-Z a-z 0-9 " +
"underscore ? * + - . characters.., pre-defined macros in case of Out going files and NO spaces embedded " +
" or trailing..");
oText.focus();
oText.select();
return false;


Thanks.

Kor
12-23-2003, 08:27 AM
good tutorials at:

http://wsabstract.com/javatutors/redev.shtml

(written by liorean, member in this forum)

or

http://www.webreference.com/js/column5/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum