...

View Full Version : Regex For Email



phantom007
10-06-2008, 07:28 PM
Hi PPL,

I wrote a regex to verify an email address



if(!preg_match("^[a-z0-9]+@{1}[a-z0-9-]+\.{1}[a-z]{2,4}\.?[a-z]{0,2}$",$myemail))
echo "Invalid Email";



Please take a look and tell me if this will work for all type of emails, For example:

abc@domain.co.uk
OR
abc@domain.info
OR
abc@domain.com

and other emails also...


Thanx

Fumigator
10-06-2008, 07:46 PM
There's a lot more to it than what you've covered. The website www.ilovejackdaniels.com has an article that discusses email validation and provides a script that does a good job of covering all email naming rules. I can't get to that website from work but if you go there and search "email" you'll find it.

phantom007
10-07-2008, 03:51 AM
Hi,

Is there any tool you use to validate this?

Fumigator
10-07-2008, 04:11 AM
Now that I'm home I can see the website and the guy changed his domain to addedbytes.com. Here's the article:

http://www.addedbytes.com/php/email-address-validation/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum