Hi,
I would like to use a regular expression to replace some parts of a text, that are not enclosed in < > (i.e. that are not HTML/PHP etc. tags).
What I mean is that if I have:
$txt = "I like this color<font color="red">!</font>";
$txt = preg_replace(...,"<b>color</b>",$txt);
// result: "I like this <b>color</b><font color="red">!</font>";
Here's what I got so far:
$term = "color";
$txt = preg_replace("/([<]\w)(".$term.")(\w[>])/i","$1<b>$2</b>$3",$txt);
But it doesn't really work 🙁
Please help, I'm going nuts here...
Thanks,
Saar.