[thelist] Email regex

Tobyn Baugher toby at rsux.com
Wed Feb 26 14:35:01 CST 2003

On Wednesday, February 26, 2003 2:40 PM -0500 Chris Evans
<evolt at unhappyfun.com> wrote:

> I use the following regex to validate email:
> ^([[:alnum:]][-a-zA-Z0-9_%\.]*)?[[:alnum:]]@[[:alnum:]][-a-zA-Z0-9%\.
> ]*\.[[:alpha:]]{2,}$

Take heart! I, and most of the people I know, just use something like
/.*@.*\..*/. Thorough it ain't, but I can't think of a really good
reason to go any further than that.

E-mail addresses have a lot of valid formats that never get used, which
is mainly why the O'reilly regex is so long. If I'm not going to go all
out and match the RFC to the letter, I'd rather let a couple invalid
ones slip by than have some one-in-a-million person sitting there
getting pissed off at my app because it won't let their valid one

Just my thoughts, and they seem to work well in the situations I find
myself in. Others probably have different needs and adjust their
thinking, and their regexs, accordingly.



Tobyn Baugher <toby at rsux.com>
aim: dieplzkthxbye  icq: 14281524  efnet: toby

More information about the thelist mailing list