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 Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 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:

    
  1. Re: [OT] Regular Expressions (Clint Davis 2003)
  2. Re: [OT] Regular Expressions (John Peacock 2003)
  3. [OT] Regular Expressions (Clint Davis 2003)
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 Peacock Director of Information Research and Technology Rowman & Littlefield Publishing Group 4501 Forbes Boulevard Suite H Lanham, MD 20706 301-459-3366 x.5010 fax 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:

Redirect frame targets (1998) simple answer? [hideif] (1997) Some ThankYou page problems (1997) [format] (1998) Database Options (1997) RE: File Uploads (1998) What's the grep? (2004) Mac carriage returns (2004) test (2003) strange IE 4.0 (1998) [WebDNA] maybe silly suggestion? [founditems] (2015) Associative lookup style? + bit more (1997) WebCat for mass emailings (1997) Card clearance, problems - solutions? (1997) Help! WebCat2 bug (1997) Inaugural meeting of the 'Oceanic WebDNA Programmers (2004) Possible Bug in 2.0b15.acgi (1997) [SHOWIF AND/OR] (1997) Sample Tearoom Search Error (1997) (1997)