note 73874 deleted from function.eregi by nlopess
| From: | nlopess@php.net | Date: | Sun, 18 Mar 2007 12:37:57 +0000 |
| Subject: | note 73874 deleted from function.eregi by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-124564@lists.php.net to get a copy of this message | ||
Note Submitter: rcsoft at gmail dot com
----
Hi everybody, I tried some email validation and this is what i came up with.
<?php
//Assuming emails should have any of these combinations
//$str = "aa@a.com";
//$str = "a1@a.com";
//$str = "a.1@a.com";
//$str = "a.1a1@a.com";
//$str = "a1.a1@a.com";
//$str = "a1.a_1@a.com";
//$str = "a1.a-1@a.com";
//$str = "a1.a_1-a@a.com";
//$str = "a1.a_1-a@a-a.com";
$str = "a1.a_1-a@a-a.com.do";
//Anything out of these examples echos wrong
$str = "a1a@a.com";
if(eregi("^[a-z]+[a-z0-9_-]*(([.]{1})|([a-z0-9_-]*))[a-z0-9_-]+
[@]{1}[a-z0-9_-]+[.](([a-z]{2,3})|([a-z]{3}[.]{1}[a-z]{2}))$",$str)) {
echo "Right<br>";
} else {
echo "Wrong<br>";
};
?>