Re: regular expressions ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> this is working fine :
> if (eregi("^-?([1-3])+$",$x)
>  echo "x is 1 or 2 or 3";

i forgot to say that doesnt work with 1-20 :(
how to do it ?


On Thu, 27 Jan 2005 16:53:55 +0100, Zouari Fourat <fourat@xxxxxxxxx> wrote:
> > if (preg_match("/[2-19]/",$x))
> >   echo "It is!";
> 
> doesnt work !
> this is working fine :
> if (eregi("^-?([1-3])+$",$x)
>  echo "x is 1 or 2 or 3";
> 
> 
> On Thu, 27 Jan 2005 08:42:19 -0700, Leif Gregory <Leifg@xxxxxxxxxxxxxxx> wrote:
> > Hello Zouari,
> >
> > Thursday, January 27, 2005, 7:33:04 AM, you wrote:
> > Z> I need to verify if $x is between 1 and 20 and i need to do that
> > Z> with regular expressions ?
> >
> > If you *need* to do it with regexp, try this:
> >
> > --------
> >
> > if (preg_match("/[2-19]/",$x))
> >   echo "It is!";
> >
> > --------
> >
> > If 1 and 20 are values you want to verify too, change 2-19 to 1-20.
> >
> > --
> > 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
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux