title: Regular expression to find and replace from complicated HTML page
body: <p>I am faced with the following issue for which I am unable to think of a good solution inspite of using regular expressions. Please help with suggestions</p>
  
  <p>I have a HTML file, which I would to highlight certain parts of the content (sentences) with the </p>
  
  <pre><code>"&lt;span style="background-color:#FFFF00"&gt;...&lt;/span&gt;" 
  </code></pre>
  
  <p>code, so that those parts are highlighted. Seems straighforward, but, the issue is that the HTML file I have contains useful information with all kinds of junk in between. Lets say the string I am interested in highlighting in my string is A= "I am pretty screwed up with this HTML"</p>
  
  <p>the original HTML code looks like :</p>
  
  <pre><code>......&lt;span class="_ _3"&gt; &lt;/span&gt;I&lt;span class="_ _3"&gt; &lt;/span&gt; &lt;span class="fc3"&gt;am&lt;/span&gt; pretty&lt;span  class="_ _3"&gt; &lt;/span&gt;screw&lt;span class="_ _3"&gt;ed&lt;/span&gt; &lt;span class="_ _3"&gt; &lt;/span&gt;up&lt;/div&gt; &lt;div class="t m0 x19 hb y5f ff4 fs7 fc2 sc0 ls0 ws0"&gt;with this&lt;span class="_ _3"&gt; &lt;/span&gt;&lt;span class="ff7"&gt;HT&lt;span class="_ _8"&gt;&lt;/span&gt;&lt;/span&gt;ML&lt;/div&gt;.....
  </code></pre>
  
  <p>I would like to use regular expressions to find the original string A and add the highlight element around it. So the final output should be</p>
  
  <pre><code>......&lt;span class="_ _3"&gt; &lt;/span&gt;&lt;span style="background-color:#FFFF00"&gt;I&lt;/span&gt;&lt;span class="_ _3"&gt; &lt;/span&gt; &lt;span class="fc3"&gt;&lt;span style="background-color:#FFFF00"&gt;am&lt;/span&gt;&lt;/span&gt; &lt;span style="background-color:#FFFF00"&gt;pretty&lt;/span&gt;&lt;span  class="_ _3"&gt; &lt;/span&gt;&lt;span style="background-color:#FFFF00"&gt;screw&lt;/span&gt;&lt;span class="_ _3"&gt;&lt;span style="background-color:#FFFF00"&gt;ed&lt;/span&gt;&lt;/span&gt; &lt;span class="_ _3"&gt; &lt;/span&gt;&lt;span style="background-color:#FFFF00"&gt;up&lt;/span&gt;&lt;/div&gt; &lt;div class="t m0 x19 hb y5f ff4 fs7 fc2 sc0 ls0 ws0"&gt;&lt;span style="background-color:#FFFF00"&gt;with this&lt;/span&gt;&lt;span class="_ _3"&gt; &lt;/span&gt;&lt;span class="ff7"&gt;&lt;span style="background-color:#FFFF00"&gt;HT&lt;/span&gt;&lt;span class="_ _8"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color:#FFFF00"&gt;ML&lt;/span&gt;&lt;/div&gt;.....
  </code></pre>