Re: Validating Subdomain E-mail Addresses Using Regular Expressions
| From: | Ivo Fokkema | Date: | Wed, 10 Sep 2003 08:01:50 +0000 |
| Subject: | Re: Validating Subdomain E-mail Addresses Using Regular Expressions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-162147@lists.php.net to get a copy of this message | ||
"Jami Moore" <jami@jamisniche.com> wrote in message
news:000001c375cf$aeb3b9c0$3900cf0c@Katya...
> I have been trying all weekend to get this right, and so far it does not
> validate an e-mail address with a subdomain.
>
> -- Code --
>
> $empatt =
> "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";
>
> if(eregi($empatt, $email))
> {
> //do stuff
> }
>
> -- End Code --
Try this pattern (which I use):
"^[-+.0-9A-Z_a-z]+@[-+.0-9A-Z_a-z]+\.[A-Za-z]{2,4}$"
HTH,
Ivo