the master
06-28-2007, 12:49 AM
Hi, im using preg_replace() on my forums for the BB codes.
Example:
$Text=preg_replace("#<b>(.*?)</b>#si", "[ B]\\1[/ B]", $Text);
now if my post has something like "[ B]this is bold[ /B]" then i get "this is bold". the problem is that its possible to put "[ B][ B]this is bold[ /B][ /B]" which gives "[ B]this is bold[ /B]".
is there a way round this without some kind of loop? maby a parameter i need to set?
Example:
$Text=preg_replace("#<b>(.*?)</b>#si", "[ B]\\1[/ B]", $Text);
now if my post has something like "[ B]this is bold[ /B]" then i get "this is bold". the problem is that its possible to put "[ B][ B]this is bold[ /B][ /B]" which gives "[ B]this is bold[ /B]".
is there a way round this without some kind of loop? maby a parameter i need to set?