title: Javascript String.replace with dynamic regular expressions?
body: <p>I have the following code, which works, but I need to inject some different stuff into the regular expression object (<code>regex2</code>) at runtime. However, text.replace does not seem to like a string object for the regular expression, so how can I make this work?</p>
  
  <pre><code>var regex2 = /\|\d+:\d+/;
  document.write("result = " + text.replace(regex2, '') + "&lt;br&gt;");
  </code></pre>