title: Can you ignore HTML in a string while doing a Replace with jQuery?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8503121/replace-words-in-a-string-but-ignore-html">Replace words in a string, but ignore HTML</a>  </p>
  </blockquote>
  
  
  
  <p>Is it possible to ignore the HTML elements when calling Replace? </p>
  
  <p>Sample code:</p>
  
  <pre><code>$myText.replace(new RegExp( $searchString, 'gi' ), 
      '&lt;span class="highlight"&gt;'+ $searchString + '&lt;/span&gt;');
  </code></pre>
  
  <p><code>$myText</code> is a large string of HTML e.g.:</p>
  
  <pre><code>var $myText = 
      "&lt;p&gt;Lorem Ipsum is simply dummy text of the printing and typesetting " +
      "industry. Lorem Ipsum has been the industry's standard dummy text " +
      "ever since the 1500s, &lt;img src="something"&gt;when an unknown printer " +
      "took a galley of type and scrambled it to make a type specimen book. " +
      "It has survived not only five centuries, " +
      "&lt;a href="#" title="Lorem"&gt;but&lt;/a&gt; also the leap into electronic " +
      "typesetting, remaining essentially unchanged. It was popularised in " +
      "the 1960s with the release of Letraset sheets containing Lorem Ipsum " +
      "passages, and more recently with desktop publishing software like " +
      "Aldus PageMaker including versions of Lorem Ipsum.&lt;/p&gt;"
  </code></pre>
  
  <p><code>$searchString</code> is equal to whatever a user types into an text input box.</p>
  
  <p>If yes, how would I do it given the above sample code?</p>