Jump to content

Archived

This topic is now archived and is closed to further replies.

thehigherentity

*SOLVED* preg_replace and case sensitivity!!!!!!!!

Recommended Posts

I'm having truble getting my head round the preg_replace, Im working on a bbcode function but cant work out if there is a way to turn the case sensative on and off, eg this is what i have at the mo
[code]
$text = preg_replace("/\[size=(\W?)(.*?)(\W?)\](.*?)\[\/size\]/",
'<span style="font-size:$2px">$4</span>', $text); // lowercase

$text = preg_replace("/\[SIZE=(\W?)(.*?)(\W?)\](.*?)\[\/SIZE\]/",
'<span style="font-size:$2px">$4</span>', $text); // uppercase
[/code]
Is there a way to write this into one pass ? so SIZE= would be treated the same as size= ?

Share this post


Link to post
Share on other sites
just sorted it on another forum, if any one is interested it just needed an i after the search like the following
[code]
$text = preg_replace("/\[size=(\W?)(.*?)(\W?)\](.*?)\[\/size\]/i",
'<span style="font-size:$2px">$4</span>', $text); // lowercase
[/code]

Share this post


Link to post
Share on other sites
Yes the i is a pattern modifier. You might want to read up on [a href=\"http://uk.php.net/manual/en/reference.pcre.pattern.modifiers.php\" target=\"_blank\"]Pattern Modifiers here[/a] also one operator you might want to use is the [b]s[/b] operator too becuase your [ size][/size] tags might span 2 or more lines otherwise the PCRE engine wont include any newline characters.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.