Re: form validation question - regex not working
| From: | DL Neil | Date: | Wed, 21 Aug 2002 20:04:11 +0000 |
| Subject: | Re: form validation question - regex not working | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21301@lists.php.net to get a copy of this message | ||
Regarding the problem you are actually asking about:
> > > if (empty($useremail) || !eregi("^([A-Za-z0-9\.\_-])+@([A-Za-z0-9\_-])
> +\.
> > > ([A-Za-z]{2,3})+$", $useremail))
> > Notice the {2,3} which is supposed to limit the last part to 2 or 3
> > letters, but I have been testing this and
> > it allows as many letters as I put in there, but not 1 only.
> > What's wrong?
Please be aware that I use PCRE not POSIX, but IIRC the last phrase says:
([A-Za-z]{2,3})+$
any upper or lower case letter,
repeated twice or three times,
and that appearing zero or more times, !!!???
appearing at the end of the string.
Remove the + immediately before the terminating $.
Regards,
=dn