Re: ereg size limit???

From: Date: Mon, 22 Apr 2002 08:43:43 +0000
Subject: Re: ereg size limit???
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93947@lists.php.net to get a copy of this message
Hi, "Sp" <internetracer@yifan.net> wrote in message news:NDBBJHKAELJNNJMBMFHDKEPJCOAA.internetracer@yifan.net... > I am trying to validate my input with ereg but I get the error "Warning: > REG_BADBR" when I try over 255 characters. Is there anyway around this? > > Works > ===== > if(eregi('^[A-Za-z]{1,255}$', "test sentence")) > echo "valid input"; > > Doesn't Work > ============ > if(eregi('^[A-Za-z]{1,256}$', "test sentence")) > echo "valid input"; First off, you're using eregi (case insensitive), but defining a-zA-Z (a through z, case insensitive) in your characters class. You could just use ereg and leave the character class as it is, or drop the A-Z from the eregi version. Secondly, I'd amend your code to: ^[a-z]+$ And thirdly, I'd just use a combination of ereg / preg_* functions and strlen. if(preg_match("/^[a-z]+$/i", $string) && strlen($string) < 255) { echo "Whatever."; } I'm not sure why you're getting that error, but then again, I haven't bothered reading up about it :) James

« previous php.general (#93947) next »