Pls help a greenhorn with not case sensitive

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-05-2004
frank
 
Posts: n/a
Default Pls help a greenhorn with not case sensitive

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


Reply With Quote
  #2 (permalink)  
Old 10-05-2004
Alexander Gilman Carver
 
Posts: n/a
Default Re: Pls help a greenhorn with not case sensitive

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'
Reply With Quote
  #3 (permalink)  
Old 10-05-2004
Michael Fesser
 
Posts: n/a
Default Re: Pls help a greenhorn with not case sensitive

.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
Reply With Quote
  #4 (permalink)  
Old 10-05-2004
frank
 
Posts: n/a
Default Re: Pls help a greenhorn with not case sensitive

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



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0