Validate email using regular expression in PHP
May 30th, 20082 Comments
Regular expressions, also referred to as regex or regexp, provide a concise and flexible means for identifying strings of text, such as particular characters, words, or patterns of characters.
Using below regex example, you can validate an email address -
eregi — Case insensitive regular expression match
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+
(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo "Valid email address.";
}else {
echo "Invalid email address.";
}

Friday, May 30th, 2008 at 7:05 am
y u don’t allow capital chars?
Friday, May 30th, 2008 at 7:05 am
Dude, eregi matches capital and non capital letters. Go to http://www.php.net/eregi if you don’t believe me.