title: Replacing tab characters in JavaScript
body: <p>Please consider the following HTML &lt;pre&gt; element:</p>
  
  <pre><code>This is some  
  example code which    
  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;contains tabs
  </code></pre>
  
  <p>I would like to replace all of the tab characters with four non-breaking space characters in HTML (i.e. &amp;nbsp;). I have tested the above pre element with JavaScript for the presence of tab characters as follows:</p>
  
  <pre><code>$('pre').ready(function() {
      alert(/\t/.test($(this).text()));
  });
  </code></pre>
  
  <p>But it is always returned false. Can anyone tell me the correct process by which to replace tab spaces from the source code to HTML NBSPs? The tabs have been added by Komodo Edit, and are visible when viewing the source.</p>