title: javascript regular expressions with variable content
body: <p>I have a working reg expression that does a replace function based on the expression. It works perfect. It finds a specific string based on the  beginning of the string and the expression. This is it:</p>
  
  <pre><code>str.replace(/\bevent[0-9]*\=/, "event");
  </code></pre>
  
  <p>what this does is it changes <code>event=1</code> to <code>event</code>.</p>
  
  <p>What if <code>event</code> was a variable word? What if I needed to look for <code>conference</code> also?</p>
  
  <p>I have tried:</p>
  
  <pre><code>var type = "conference";
  
  str.replace(/\b/ + type+ /[0-9]*\=/, "conference");
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>str.replace(/\b/type/[0-9]*\=/, "conference");
  </code></pre>
  
  <p>neither worked.</p>
  
  <p>how can I pass a javascript string into a regular expression?</p>