Re: Regex for email validation
| From: | Yeti | Date: | Wed, 27 Aug 2008 16:12:39 +0000 |
| Subject: | Re: Regex for email validation | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278783@lists.php.net to get a copy of this message | ||
<?php
# this one worked fine for me, but it does not cover the full RFC
like: "name" name@notworking.cc OR name <name@notworking.cc>
$regex =
"^[a-z0-9,!#\$%&'\*\+/=\?\^_
\{\|}~-]+(\.[a-z0-9,!#\$%&'\*\+/=\?\^_\{\|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})$";
if (eregi($regex, $email)) {
// do something
}
# Beware that the filter functions only work under PHP5+. If your PHP
supports them they should be the preferred choice
?>