Re: regular expressions ?

From: Date: Thu, 27 Jan 2005 17:04:51 +0000
Subject: Re: regular expressions ?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-207511@lists.php.net to get a copy of this message
Hello Zouari, Thursday, January 27, 2005, 8:53:55 AM, you wrote: Z> doesnt work ! Z> this is working fine : Z> if (eregi("^-?([1-3])+$",$x) Z> echo "x is 1 or 2 or 3"; Whoops. Sorry.. That's what I get for throwing out an answer while on the run: Try this: <?php for ($x=0; $x < 120; $x++) { if (preg_match("/^([1-9]{1}|1[0-9]{1}|20)$/",$x)) echo "It is! " . $i . "<br>"; else echo "It's not!" . $i . "<br>"; } ?> The for loop is just for show. -- Leif (TB lists moderator and fellow end user). Using The Bat! 3.0.2.3 Rush under Windows XP 5.1 Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB

« previous php.general (#207511) next »