Consider the following variables
$line = "<FONT color=\"#ff0060\">Color</FONT> printers are laser color printers";
$match_str = "color";
I have to match and replace $match_str in $line with <FONT color="#ff0060">$match_str</FONT>. But 'color' inside <FONT> tag should not be matched and replaced .
My output should be
<FONT color="#ff0060">Color</FONT> printers are laser <FONT color="#ff0060">color</FONT> printers .
I am searching for 'color' ($match_str) in the given $line to highlight that word in red color . The pattern should not match 'color' inside the FONT tag . But it should match and highlight the word 'color' in the line other than the one inside FONT .
How to search this pattern match and replace ?
Thanks for the help.