By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,719 Members | 1,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,719 IT Pros & Developers. It's quick & easy.

Pls help a greenhorn with not case sensitive

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
frank <sp***@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'
Jul 17 '05 #2

P: n/a
.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
Jul 17 '05 #3

P: n/a
Great thanks! This did the trick.
All I did was enter that 'i' after the '#' and whammo!!
much appreciated!
"Michael Fesser" <ne*****@gmx.net> wrote in message
news:6j********************************@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

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.