Re: PCRE regexp bug ?
| From: | Curt Zirzow | Date: | Fri, 15 Aug 2003 16:43:40 +0000 |
| Subject: | Re: PCRE regexp bug ? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-159719@lists.php.net to get a copy of this message | ||
* Thus wrote Curt Zirzow (curt@zirzow.dyndns.org):
> * Thus wrote tpc@csua.berkeley.edu (tpc@csua.berkeley.edu):
> >
> > I use preg_match to validate the Middle Initial field of a form and so far
> > it works, except yesterday a user submitted a "0" (zero) as a middle
> > initial! My regexp is:
> >
> > if (!empty($_POST[MI]) && (preg_match('/^[[:alpha:]]{1,1}$/',
> > $_POST[MI]) == 0))
> >
> > I tested it with 0-9 and my regexp catches every digit except 0. Curious...
>
> actaually 0-9 will never match that regexp.
Oops after reading my post to your post I see that is what you
wanted. sorry.
the 0 problem can be fixed by checking strlen($_POST[MI]) or
isset() instead of !empty().
Curt
--
"I used to think I was indecisive, but now I'm not so sure."