Re: [OT] Regular Expressions
This WebDNA talk-list message is from 2003
It keeps the original formatting.
numero = 49877
interpreted = N
texte = Clint Davis wrote:> I'm trying to use a regular expression in a javascript to test an email> input field in a form like this:> > var goodEMAIL = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/> You will need to escape the period when it does not appear inside a set [] since it is otherwise a match any single character term. Try this instead:var goodEMAIL = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/> I thought this script was supposed to act as specified above, but I'm able> to enter something like a@aaaa with no problems, but a@a.a fails. The 2-4> character check at the end doesn't appear to be working. I'm sure one of the> veteran C programmers can answer this with no problem.> The reason that a@a.a fails is that the 2-4 check _is_ working; you cannot have fewer than two characters in your TLD (corresponding to the ISO country codes). However, I think the {2,4} should be changed to {2,} since there may now be domains longer than 4 characters (e.g. .museum). The reason that a@aaaa is working is that you are actually matching it like this: (a)@(aa)(aa)because you didn't escape the period.HTHJohn-- John PeacockDirector of Information Research and TechnologyRowman & Littlefield Publishing Group4501 Forbes BoulevardSuite HLanham, MD 20706301-459-3366 x.5010fax 301-429-5748-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list
.To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
Associated Messages, from the most recent to the oldest:
Clint Davis wrote:> I'm trying to use a regular expression in a javascript to test an email> input field in a form like this:> > var goodEMAIL = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/> You will need to escape the period when it does not appear inside a set [] since it is otherwise a match any single character term. Try this instead:var goodEMAIL = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/> I thought this script was supposed to act as specified above, but I'm able> to enter something like a@aaaa with no problems, but a@a.a fails. The 2-4> character check at the end doesn't appear to be working. I'm sure one of the> veteran C programmers can answer this with no problem.> The reason that a@a.a fails is that the 2-4 check _is_ working; you cannot have fewer than two characters in your TLD (corresponding to the ISO country codes). However, I think the {2,4} should be changed to {2,} since there may now be domains longer than 4 characters (e.g. .museum). The reason that a@aaaa is working is that you are actually matching it like this: (a)@(aa)(aa)because you didn't escape the period.HTHJohn-- John PeacockDirector of Information Research and TechnologyRowman & Littlefield Publishing Group4501 Forbes BoulevardSuite HLanham, MD 20706301-459-3366 x.5010fax 301-429-5748-------------------------------------------------------------This message is sent to you because you are subscribed to the mailing list .To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/
John Peacock
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
Purchase command error problem (1997)
Database location (2002)
WebStar WebCat Crashing a lot (2004)
database visibility (2000)
Problems setting MIME Headers (1998)
ReturnRaw and redirect one last question (1997)
Re2: frames & carts (1997)
Emailer setup (1997)
Show items based on login Password (2003)
[WebDNA] Announcing the new features for the next WebDNA version (2015)
WebCatalog can't find database (1997)
showif comparison begins w/ and contains (1997)
User .db Questions (1999)
WebCat2 several catalogs? (1997)
WebCat2b14MacPlugIn - [include] doesn't hide the search string (1997)
More Applescript (1997)
Include binary files in template/XML (SOLVED/Request new (2004)
problems with 2 tags (1997)
Problems with Price field (1997)
Webcat deletes last line from Excel-saved text db (2004)