Re: Regex for email validation
| From: | Per Jessen | Date: | Wed, 27 Aug 2008 16:33:49 +0000 |
| Subject: | Re: Regex for email validation | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278787@lists.php.net to get a copy of this message | ||
Yeti wrote:
> <?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,})$";
For the domain part, I would check against
"@([a-z0-9-]+\.)+[a-z0-9-]+"
and then do a lookup for an A record. There are still some patterns
that will fit the above, without being valid domain-names.
/Per Jessen, Zürich