[UPHPU] Email address format in regular expression
Walt Haas
haas at xmission.com
Thu Dec 29 13:21:11 MST 2005
The standard is RFC 2822 (http://www.ietf.org/rfc/rfc2922.txt)
The format of an address is defined on pages 15-18.
But I just punt to PEAR function Mail_RFC822::parseAddressList()
http://pear.php.net/manual/en/package.mail.mail-rfc822.parseaddresslist.php
-- Walt
Cabot Nelson <adjustable_pliers at yahoo.com> wrote:
> Using the ereg() function in PHP (http://us2.php.net/manual/en/function.ereg.
> php), I'm using this lengthy expression to determine a properly formatted ema
> il address:
>
> ^([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-
> 4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5
> ])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0
> -9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z
> 0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$
>
> However, I know very little about regular expressions and don't know if this
> is accurate. It seems to work. Is this the best expression for an email addr
> ess? Is there an *official* format as determined by the email protocol?
>
> Many thanks.
>
> -Cabot Nelson
>
>
>
> _______________________________________________
>
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
-------
Walt Haas The Web Site Doctor - Cures Sick Web Sites
(801) 534-1262 http://thewebsitedoctor.net
More information about the UPHPU
mailing list