title: Javascript search and replace
body: <p>I would like do do the following in Javascript (pseudo code):</p>
  
  <pre><code>myString.replace(/mypattern/g, f(currentMatch));
  </code></pre>
  
  <p>that is, replace string isn't fixed, but function of current match.</p>