[nycphp-talk] Validating Email Addresses
Dan Cech
dcech at phpwerx.net
Thu Dec 2 10:58:04 EST 2004
Hi All,
I've come up against an interesting little problem, and wondered if
anyone had any input for me.
I'm trying to validate email addresses like:
Joe Bloggs <joe at example.com>
Thus far the best I've come up with is:
$preg = '/^(?:("?)([^"<]+)\1
<)?(([\w.-]+)@((?:[a-z0-9-]+\.)+[a-z0-9]{1,4}))(?:>?)$/i';
Which results in:
Array (
[0] => Joe Bloggs <joe at example.com>
[1] =>
[2] => Joe Bloggs
[3] => joe at example.com
[4] => joe
[5] => example.com
)
Does anyone have any input on this?
Dan Cech
More information about the talk
mailing list