Re: eregi filter stopping valid email address, part two
| From: | CPT John W. Holmes | Date: | Tue, 06 Jan 2004 16:16:52 +0000 |
| Subject: | Re: eregi filter stopping valid email address, part two | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173863@lists.php.net to get a copy of this message | ||
From: "Dave G" <ml@autotelic.com>
> A while ago on this list I posted a few questions about an eregi
> filter for email addresses entered into a form. With the help of people
> on this list, I settled on the following code which has worked fine in
> the months since I started using it. The code is this:
>
> eregi('^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9-]+.[a-zA-Z.]+$', $email)
>
> But recently, a person was unable to get their email to pass
> this eregi test. The email is valid, as they are able to send email to
> me. It has the following format:
>
> xxxxxxxx@xx1.xx-xxx.ne.jp
>
> Shouldn't this email pass? I've allowed for hyphens after the @
> mark. Is it that there are two many periods?
You're only allowing hyphens in the first part of the address after the @
symbol, though, before the first period. Maybe your regex should be:
@([a-zA-Z0-9-]+\.)+[a-zA-Z.]
Just noticed that your period is not escaped, either, so you're actually
matching any character with the one that's outside of the [ and ] character
classes.
---John Holmes...