http://www.perlmonks.org?node_id=129760

mike2771 has asked for the wisdom of the Perl Monks concerning the following question: (regular expressions)

I would like to determine whether an email address is valid.
Is there a regular expression or something I can use to do this?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I validate an email address?
by vagnerr (Prior) on Oct 28, 2006 at 11:10 UTC
Re: How do I validate an email address?
by runrig (Abbot) on Dec 06, 2001 at 01:20 UTC
Re: How do I validate an email address?
by runrig (Abbot) on Dec 06, 2001 at 01:18 UTC
Re: How do I validate an email address?
by reneeb (Chaplain) on Jul 19, 2004 at 08:54 UTC
Re: How do I validate an email address?
by greenFox (Vicar) on Oct 30, 2006 at 13:35 UTC
    Recipe 6.19, "Matching a Valid Mail Address", in The Perl Cookbook gives a broader coverage of this topic and is well worth a read. In it, Tom Christiansen refers to his attempt at a regular expression (while admitting that it's less than perfect) which can be found in his script, ckaddr. It is based on a regular expression in Recipe 18.9 of Mastering Regular Expressions. All of this proves (to me at least) just how tricky matching an email address really is.
Re: How do I validate an email format?
by Anonymous Monk on Aug 01, 2002 at 17:49 UTC
    Not easily. Try: http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

    Originally posted as a Categorized Answer.

Re: How do I validate an email format?
by Anonymous Monk on Mar 23, 2003 at 07:45 UTC
    /.*\@\.com|edu|gov|net/

    Originally posted as a Categorized Answer.

A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.