Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: regexp to only allow for formally valid email addresses

by w-ber (Hermit)
on Mar 07, 2007 at 17:53 UTC ( #603656=note: print w/ replies, xml ) Need Help??


in reply to regexp to only allow for formally valid email addresses

Use Mail::RFC822::Address. Also, the Regular Expression Library has some pretty interesting constructs.

As to your regex, I don't see anything wrong in it, and it works with a couple of test cases as it should:

$ perl -e 'print "valid\n" if ("foo\@bar" =~ m/^[a-zA-Z_\-.0-9]+@[a-zA +-Z_\-.0-9]+$/);' valid $ perl -e 'print "valid\n" if ("j.random.hacker\@perlmonks.com" =~ m/^ +[a-zA-Z_\-.0-9]+@[a-zA-Z_\-.0-9]+$/);'

Of course, tests can never show the absence of errors. But I'm willing to bet you have a problem somewhere else in the program.

UPDATE: Seems like others beat me to it... I just remembered that there was some nice discussion about this over at The Daily WTF.

--
print "Just Another Perl Adept\n";


Comment on Re: regexp to only allow for formally valid email addresses
Download Code
Re^2: regexp to only allow for formally valid email addresses
by fraktalisman (Hermit) on Mar 08, 2007 at 08:26 UTC
    w-ber wrote:
    Of course, tests can never show the absence of errors. But I'm willing to bet you have a problem somewhere else in the program.

    If we had bet, you'd won ;)
    There was another parameter that goes into the email header. The $f{'Email'} field validation was not the actual problem ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://603656]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-07-28 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (193 votes), past polls