> Sorry, but that doesn't work.  I thought it would, but it only does two
> characters on the top level domain again. Tested at
> http://www.php.comzept.de/rexpr (thanks Jörg!)
>
> Does anyone else (a regex guru) have any other suggestions?

The most recent regex you had:
        ([a-z0-9_\.\-]+)@([a-z0-9\.-]+).([a-z]{2,3})

would still allow addresses such as [EMAIL PROTECTED]  or _.-._.@.-.com.

(Actually, with the . there, you could even have _.-._.@.-|com)

Regardless, here's a regex I've adjusted to try and keep the address as
close to good form as possible:

        "^[0-9a-z]+([-_./]([0-9a-z]+))*@[0-9a-z]+([-.]([0-9a-z]+))*\\.[a-z]{2,4}$"

A little longer, but it does the trick (I've tried hitting it with a bunch
of possibilities, but I may have missed some. <G>)  We have some lists that
contain (valid) email addresses like [EMAIL PROTECTED], so I've allowed a /
as a separator to the left of the @.  (If you don't want to allow this, just
replace [-_./] with [-_.] and it'll be gone.

At the end of the regex, I allow 2-3 characters but this may need to be 2-5
shortly since the new TLDs may start coming into use.  Up to you.

Make sure you use eregi instead of just ereg, or lowercase the email address
before you check it.

We also go a step further and use checkdnsrr to see if there are any (type
ANY that is) records available for the hostname part.  Not great, but it at
least tries to see if the hostname exists.

Let me know if it works out for you.

Jaime Bozza
GeoComm International Corp.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to