[wp-hackers] is_email

Nikolay Bachiyski nbachiyski at developer.bg
Fri Mar 25 16:12:24 GMT 2005


Here is the regular expression found in the is_email() function:

$chars = "/^([a-z0-9+_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,6}\$/i";

Some questions arose when I was looking at it:
- why is it possible to have a '+' in the username
- why is it possible to have '-' in both the username and the host
- is there any difference between ([a-z0-9_]|\\-|\\.)+ and [a-z0-9_\-.]+
- isn't it better to put it into single quotes and save some backslash 

Here is a suggestion:

$email_regex = '/^[a-z0-9_\-.]+\@([a-z0-9\-]{1,255}\.)+[a-z]{2,6}$/i';


More information about the wp-hackers mailing list