Hi, I'm using the following as a regular expression for email validation, but I realized it doesn't work in the case where the domain is multipart (such as someone@houston.rr.com ) Here is my current regular expression: [a-zA-Z0-9-]+@[a-zA-Z0-9-]+.[a-zA-Z]+$
Can someone help me to change this to allow emails that contain subdomains in the name.
Thanks for any suggestions
try this - it works with both
$reg="^[a-z0-9]+(\\.|_|-)?[a-z0-9]+@[a-z0-9]+\\.([a-z0-9]+\\.)?[a-z0-9]{2,4}$"; $email="someone@hello.world.com"; echo preg_match("/$reg/i",$email);
thats the one i use sometimes