Hi
I'm trying to make a simple text formatting thing using curly brackets where
{ text } = bold
{{ text }} = italic
etc
so i'm using this to replace the brackets in the text
$str = preg_replace('/\{/', '<span class="bold">', $str);
$str = preg_replace('/\}/', '</span>', $str);
the problem is that with a double bracket it replaces each one twice :
<span class="bold"><span class="bold">text</span></span>
so i ended up putting them in reverse order so that 3 brackets are replaced first, then two, then one
that works fine but i'd be interested to know what I would need to do to make it count the number of brackets before doing the replacing ?
thanks