Re: preg, patern quantifier limit
| From: | Curt Zirzow | Date: | Fri, 01 Aug 2003 21:04:41 +0000 |
| Subject: | Re: preg, patern quantifier limit | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158004@lists.php.net to get a copy of this message | ||
* Thus wrote Yann Larrivee (yannl@istop.com):
> Hi, i did a standard preg [A-Za-z0-9]{1,65536}
>
> What i am simply trying to do is to validate the a form that will insert
> into my TEXT database field. So i just want to prevent a larger insert
> then expected.
>
>
> PHP trows me this error "preg_match(): Compilation failed: number too
> big in {} quantifier at offset 19 ..."
>
>
> So it appears that quantifiers are limited. Anybody knows what that
> limit is ?
It looks like it should be 65535, which makes more sense because
that is the unsigned word boundry.
if you inisist on having a 65536 limit use strlen with the preg
if (strlen($str) <= 65536 && preg_match('/[A-Za-z0-9]+/', $str)) {
HTH,
Curt
--
"I used to think I was indecisive, but now I'm not so sure."