On Wednesday, May 1, 2002, at 12:43 , McElwee, Shane wrote:
> Below I've a regular expression that checks the syntax of an email > address. > The problem I'm having is with the underscore "_" . I've tried some > different forms of syntax but I know its something simple I'm missing. I > think I've been looking at it too long. The validator should allow > usernames with periods and underscores. Any ideas? > > next if (!/^[\w][\w\._-]*@[\w\.-]+$/) since john has pointed out the need to guard the "@" - let me suggest and underscore the 'unless' syntax - unless (<Conditional>) == if ( !<Conditional>) At which point you might want to look at: http://examples.oreilly.com/regex/email-opt.txt which provides a lovely regular expression solution for this classic problem.... since if you follow John's advice on the faq - you will notice that you are wandering into the classically simplistic regEx that will also blow away some 'legitimate' RFC822 and RFC2822 compliant email addresses - ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]