Re: Regex for email validation

From: Date: Wed, 27 Aug 2008 15:15:38 +0000
Subject: Re: Regex for email validation
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-278778@lists.php.net to get a copy of this message
At 9:31 AM +0200 8/27/08, Per Jessen wrote:
VamVan wrote:
Hello Guys, Does any have a regex for email validation? I need to allow only period and underscore in the local part , we would need a @ and .com or watever for domain.
Option 1: /^[_.]+@[a-z0-9-]+\.com$/ This is probably what you meant: /^[a-z0-9_.]+@[a-z0-9-]+\.com$/ /Per Jessen, Zürich
Which is probably what you meant: eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $email) Email comes in different TLD flavors. But, even that still doesn't cover all the possible and legal Unicode code-points that can exist on both sides of the @ of an email address. For example: tedd@ˆ.com is a legal and working email address. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#278778) next »