I have a regular expression using word boundaries that works exceedingly well...
~\b('.$value.')\b~i
...save for the fact that it matches text inside HTML tags (i.e. title="This is blue!"
). It's a problem because I'm doing text substitution on anything the regex matches, then making tooltips appear using those title tags. So, as you can imagine, it's substituting text inside the title and breaking the HTML of the tooltip. For example, what should be:
<span class="blue" title="This is blue!">Aqua</span>
...ends up becoming...
<span class="blue" title="This is <span class=" blue"="">Royal Blue</span>">Aqua</span>
My use of strip_tags didn't solve the issue; I think what I need is a better regular expression which simply will not match content ending in blue">
('blue' in this case being placeholder for any other color in the array I'm comparing it against).
Can anyone append what I need to the regular expression? Or do you have a better solution?