Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    India
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help with using regular expression

    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?

    Code:
    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.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    good tutorials at:

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

    (written by liorean, member in this forum)

    or

    http://www.webreference.com/js/column5/
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •