On [Fri, 01.02.2008 03:55], Phrogz wrote:
> On Jan 31, 10:12 am, Dominik Honnef <domini... / gmx.net> wrote:
> > On [Fri, 01.02.2008 01:14], Eric H. wrote:
> >
> > > Anyone have a code snippet that tells whether an email address is
> > > "valid" but not necessarily whether it is a working address because that
> > > much I can sort out through my mail server through any bounces.
> >
> > > I have a database of addresses where the person entering the data has a
> > > bad, bad, bad, BAD habit of not validating them before entering them and
> > > so I get things like "***DO NOT SHARE DATA***" and "lmnopaol.com" and
> > > the like. It's not my company or else she'd be going over all the
> > > entries by hand.
> >
> > > Thanks in advance
> >
> > email = "em... / host.tld"
> > email2 = "email / h...@ost.tld"
> >
> > email =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
> > #=> true/0
> > email2 =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
> > #=> nil/false
> 
> One of my email addresses is:
>   !@phrogz.net
> This is completely valid, and not even very crazy. The proliferation
> of half-assed regular expressions like the above prevents me from
> using that address on lots of web sites.
> 
> You cannot EXACTLY validate the syntax of an email address using only
> regular expressions. You can get close, but you need a much better
> regexp than the above.
> 
> Here are some more syntactically valid email addresses:
>   "Me Here"@phrogz.net
>   phrogz@[69.46.18.236]
>   phrogz@(go)[69.46.18.236](me(yeah))

And as nearly no website nor many email clients (i even believe, that some email servers will fail on this adresses)
can handle this kind of email addresses, it shouldn't be a huge problem to use this regex.
Of course it isn't the best solution, but it probably covers about 99% of all valid email adresses. 
And i prefer covering 99% of valid adresses over allowing a lot more invalid adresses.
-- 
Dominik Honnef