View Full Version : preg_replace problems (again)

06-20-2006, 04:12 AM
I'm trying to create the equivalent of for my site.
But everything I try, only works a little bit, or not at all.
here's what I got now:

//do function
function doNoParse($tstring){
$newtext = preg_replace("|\[(.*?)\]|i","[*$1]",$tstring);
return $newtext;

//test string
$text = "this is a test thread!

this shouldn't parse.. at all
this would be green!
this should be seen
this would be yellow!

this should be blue!";

//strip out noparse tags and process tags within
$text = preg_replace("(\[noparse\](.*?)\[\/noparse\])i",doNoParse("$1"),$text);

//echo the finished product
echo $text;

but it just parses the color tags within the noparse tags...