Case insensitive RegEx?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gleeb
Forum Commoner
Posts: 87
Joined: Tue May 13, 2003 7:01 am
Location: UK
Contact:

Case insensitive RegEx?

Post by Gleeb »

I want to do something like '#\<title\>([/w/W]+)\</title\>#', but as you can see, it'll only match <title></title>. I can't seem to be able to tell how to make it case insensitive. Help? :(
Gleeb
Forum Commoner
Posts: 87
Joined: Tue May 13, 2003 7:01 am
Location: UK
Contact:

Post by Gleeb »

*bump*
[thefly]Help Meeeee![/thefly]
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Just add an 'i' at the end:

Code: Select all

#\<title\>(&#1111;/w/W]+)\</title\>#i
Mac
Gleeb
Forum Commoner
Posts: 87
Joined: Tue May 13, 2003 7:01 am
Location: UK
Contact:

Post by Gleeb »

That's it? Damn it :|
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

yes.

posix ones are done in php by adding an i to the function call (ereg v eregi) and perl are done in the pattern.

in perl you have i for case insensitive and g fro global.


so '|<pattern>|i' is insensitive to case and | needs to be escaped in the pattern
Post Reply