[thelist] Email regex

Chris Evans evolt at unhappyfun.com
Wed Feb 26 13:40:01 CST 2003


I use the following regex to validate email:

^([[:alnum:]][-a-zA-Z0-9_%\.]*)?[[:alnum:]]@[[:alnum:]][-a-zA-Z0-9%\.]*\.[[:alpha:]]{2,}$

When doing some code review, I was asked whether this is the "industry
standrd" email validation.  Does anybody have a better one, or
sugestions on how to improve it?  I don't want to go overboard and use
the 6598 character regex in the back of the O'Reilly "mastering Reg Ex"
book, but want to make sure I'm validating in a good way.

Thanks,

Chris Evans
http://www.bluejackcode.com





More information about the thelist mailing list