0

What is the recommended way to validate an email using perl ?

What I had tried so far :

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
MevatlaveKraspek
  • 2,246
  • 3
  • 20
  • 23
  • 1
    See http://en.wikipedia.org/wiki/Email_address, also see the discussion page http://en.wikipedia.org/wiki/Talk:Email_address for the answer – QuentinUK Feb 19 '13 at 10:59
  • 2
    There is a nice example of how to do this in one regex in [Mastering Regular Expressions](http://shop.oreilly.com/product/9781565922570.do) by O'Reilly. You will like it. It looks a lot like yours, just a tiny bit longer. – simbabque Feb 19 '13 at 12:30
  • 1
    I think the *Perl* answer is [use Regexp::Common qw;](http://cpan.org/perldoc?Regexp::Common::Email::Address) – Axeman Feb 19 '13 at 14:25

0 Answers0