Re: regex for ordinal numbers - working with it two days and Ihate r egex...

From: Date: Thu, 24 Aug 2000 19:12:38 +0000
Subject: Re: regex for ordinal numbers - working with it two days and Ihate r egex...
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-2119@lists.php.net to get a copy of this message
"Asendorf, John" wrote: > While I wait for Mastering Regular Expressions (O'Reilly) to get here, could > someone give me a hand with this regex? > > if (eregi( "([0-9]{1,2})+([a-z]{1,2})" , $piece[1] ) { > echo "running the ordinal changer"; > } > > It's **supposed** to look for 1 or 2 numbers followed by 1 or 2 uppercase > letters such as 1ST or 2ND or 15TH or 23D > > I'm not really sure that what is above is even close... all I know is that > it's not picking it up in its present form... > > Thanks in advance, > > John 1) Try removing the '+' from the middle of your expression (+ means "one or more of the previous char") which you don't need since you already denoted {1,2} "between 1 and 2 of previous char". 2) Letters in set ranges... [a-z]... are CASE SENSITIVE :). Try [A-Za-z] instead (making this match any letter, either upper or lower-case) -- Andy Hoffman Web Developer Bristol-Myers Squibb email: andy.hoffman@bms.com

« previous php.windows (#2119) next »