Jump to content

*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= ?
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.