Hi,
I thought I had set out to do something simple but turns out maybe its not...
I have a string $str that contains [code] blah blah [/code] tags. All I would like to do is replace the content of the code tag with htmlspecialchars('[code] blah blah [/code]')
I figured preg_replace would be my best option so I finally figured out an expression that would work. The expressions I found online didn't seem to work for my newlines... Anyways so I found this expression to work:
'/[code][\s\S]*[\/code]/i'
So I thought every thing was good and I tried to do this:
$str = preg_replace('/[code][\s\S]*[\/code]/i', htmlspecialchars('$1'), $str);
No luck! Seems like $1 is empty. If I try putting a regular string ie htmlspecialchars('&') it does work.
Not sure what I am doing wrong but would really appreciate some assistance!
Thanks,
slevytam