title: JS .replace place b tag in string where == string
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/280793/case-insensitive-string-replacement-in-javascript">Case insensitive string replacement in JavaScript?</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to highlight part of a string where it is equal to another variable value.</p>
  
  <p>For example</p>
  
  <pre><code>var string = 'This Is A Test String';
  var findWord = 'test';
  </code></pre>
  
  <p>result should be </p>
  
  <pre><code>'This Is A &lt;b&gt;Test&lt;/b&gt; String'
  </code></pre>
  
  <p>Please note the case insensitive and that I require the use of using variables to pass the 'find/Replace word'</p>
  
  <p>reason I need to do it this was is to keep the exact form/case of the string found where is == to the search word.</p>
  
  <p>In PHP, this works, so basically I'm after the JS equivalent of</p>
  
  <pre><code>preg_replace('/('.$search.')/i','&lt;b&gt;$1&lt;/b&gt;',$val['name'])
  </code></pre>
  
  <p>I'm not good when it comes to regex, this should be simple for someone.</p>