title: Case insensitive string replacement in JavaScript?
body: <p>I need to highlight, case insensitively, given keywords in a JavaScript string.</p>
  
  <p>For example:</p>
  
  <ul>
  <li><code>highlight("foobar Foo bar FOO", "foo")</code> should return <code>"&lt;b&gt;foo&lt;/b&gt;bar &lt;b&gt;Foo&lt;/b&gt; bar &lt;b&gt;FOO&lt;/b&gt;"</code></li>
  </ul>
  
  <p>I need the code to work for any keyword, and therefore using a hardcoded regular expression like <code>/foo/i</code> is not a sufficient solution.</p>
  
  <p>What is the easiest way to do this?</p>
  
  <p>(This an instance of a more general problem detailed in the title, but I feel that it's best to tackle with a concrete, useful example.)</p>