title: highlight words in html using regex in C#
body: <p>I found this article on stackoverflow</p>
  
  <p><a href="https://stackoverflow.com/questions/10416643/highlight-words-in-html-using-regex-javascript-almost-there">highlight words in html using regex &amp; javascript - almost there</a></p>
  
  <p>Using the article above, I am trying to highlight HTML text on the server using c#.  The code is shown below:</p>
  
  <pre><code>string replacePattern = "$1&lt;span style=\"background-color:yellow\"&gt;$2&lt;/span&gt;";
  string searchPattern = String.Format("(?&lt;=^|&gt;)(.*?)({0})(?=.*?&lt;|$)", searchString.Trim());
  content = Regex.Replace(content, searchPattern, replacePattern, RegexOptions.IgnoreCase);
  </code></pre>
  
  <p>The code seems to work great except when trying to highlight a word that is contained in an image source:</p>
  
  <p><strong>Search Keyword:</strong></p>
  
  <pre><code>ABC
  </code></pre>
  
  <p><strong>Search Text:</strong></p>
  
  <pre><code>&lt;div&gt;&lt;img src="/site/folder/ABC.PNG" /&gt;&lt;br /&gt;ABC&lt;/div&gt;
  </code></pre>
  
  <p>The result will highlight both the text and the image name.</p>
  
  <p>Any help would be greatly appreciated.</p>