My objective is to replace all pattern words that match a particular regex with that word surrounded in some html tags like so.
<p>This is some text where the word text will get surrounded by something else.</p>
<p>This is some <span class='mydiv'>text</span> where the word <span class='mydiv'> will get surrounded by something else.</p>
Note that as this is a simple example used to illustrate my problem, I cannot simply do this...
The original problem comprises a large regular expression that will accept a large range of inputs and the text is allowed to contain spaces. So text, t E x T and other derivatives will be allowed and I wouldn't want to change the original styling/format to a static replacement word "text" I'd like the original wording/casing etc. there within the replacement.
Anyone know how to do this?