Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Preg Replace help


Readie - 6:14 pm on Jun 29, 2010 (gmt 0)


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.


Thread source:: http://www.webmasterworld.com/php/4161055.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com