Might be best to convert all square brackets to their html entity counterpart inside the "escape" tags first, and remove the escape tags. Then run the main part of the BB code script, like so:while(preg_match('/\[esc\](.*?)\[\/esc\]/im', $input, $out)) { $repl = str_replace('[', '[', $out[1]); $repl = str_replace(']', ']', $repl); $input = str_replace($out[0], $repl, $input); unset($repl, $out); } Note: I suggest using an escape tag, so people can still parse BB code inside of your code tags.
|