This is a discussion on Pls help a greenhorn with not case sensitive within the PHP Language forums, part of the PHP Programming Forums category; I have this: preg_match('#^(ab[0-9]+)(?:/([0-9]+))*$#', $_SERVER['QUERY_STRING'], $matches); And this seems to only work with queries ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have this:
preg_match('#^(ab[0-9]+)(?:/([0-9]+))*$#', $_SERVER['QUERY_STRING'], $matches); And this seems to only work with queries containing 'ab' lower case, I need it to allow for 'AB' as well. I'd be greatful if someone could offer a solution to this. TIA |
|
|||
|
frank <spamo@no.com> summoned the power of the electron to profess:
| I have this: | preg_match('#^(ab[0-9]+)(?:/([0-9]+))*$#', $_SERVER['QUERY_STRING'], | $matches); | And this seems to only work with queries containing 'ab' lower case, I need | it to allow for 'AB' as well. | I'd be greatful if someone could offer a solution to this. | TIA It only works for lowercase 'ab' because that's all you asked for. If you want upper and lower case versions of 'A' and 'B' you have to explicitly ask for it: #^[Aa][Bb][0-9]+ ... This would match all versions of 'A' and 'B' together: 'ab', 'Ab', 'aB', 'AB' #^[ab|AB][0-9]+ ... This would match either 'ab' or 'AB' |
|
|||
|
.oO(frank)
>I have this: >preg_match('#^(ab[0-9]+)(?:/([0-9]+))*$#', $_SERVER['QUERY_STRING'], >$matches); > >And this seems to only work with queries containing 'ab' lower case, I need >it to allow for 'AB' as well. >I'd be greatful if someone could offer a solution to this. Quite easy. preg_match('#^(ab[0-9]+)(?:/([0-9]+))*$#i', ... ^ <http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php> | i (PCRE_CASELESS) | | If this modifier is set, letters in the pattern match both upper and | lower case letters. Micha |
|
|||
|
Great thanks! This did the trick.
All I did was enter that 'i' after the '#' and whammo!! much appreciated! "Michael Fesser" <netizen@gmx.net> wrote in message news:6j94m09jv67k7ddo7i2c0ene31daan1bot@4ax.com... > .oO(frank) > >>I have this: >>preg_match('#^(ab[0-9]+)(?:/([0-9]+))*$#', $_SERVER['QUERY_STRING'], >>$matches); >> >>And this seems to only work with queries containing 'ab' lower case, I >>need >>it to allow for 'AB' as well. >>I'd be greatful if someone could offer a solution to this. > > Quite easy. > > preg_match('#^(ab[0-9]+)(?:/([0-9]+))*$#i', ... > ^ > <http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php> > > | i (PCRE_CASELESS) > | > | If this modifier is set, letters in the pattern match both upper and > | lower case letters. > > Micha |