title: jQuery: How to wrap RegEx matched plain text in an anchor tag?
body: <p>Suppose I have an HTML page that looks something like this:</p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;
  00123
  &lt;input value="00123"&gt;
  00456
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>And I want to use javascript/jQuery to make it look like this:</p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;
  &lt;a href="#00123"&gt;00123&lt;/a&gt;
  &lt;input value="00123"&gt;
  &lt;a href="#00456"&gt;00456&lt;/a&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Essentially I want to wrap regular expression matched plain strings in the document with HTML anchor tags. In this example, I want to do something like:</p>
  
  <pre><code>$('body').html($('body').html().replace(/(00\d+)/, '&lt;a href="#$1"&gt;$1&lt;/a&gt;'));
  </code></pre>
  
  <p>See the jsFiddle with this example: <a href="http://jsfiddle.net/NATnr/2/" rel="nofollow">http://jsfiddle.net/NATnr/2/</a></p>
  
  <p>The problem with this solution is that the text inside the <code>input</code> element is matched and replaced.</p>
  
  <p>Does anyone know how to only match and replace plain text in a document in this manner using javascript/jQuery?</p>