title: How to pass a regular expression as a function parameter
body: <p>Why this returns false instead of true.</p>
  
  <pre><code>function doit(expression) {
  
      var regex = new RegExp(expression, 'g');
  
      alert(regex.test('mename@memail.com'));
  }
  
  doit("/^\w+([-+.\']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/");
  ​
  </code></pre>
  
  <p><a href="http://jsfiddle.net/hAV8Q/" rel="noreferrer">http://jsfiddle.net/hAV8Q/</a></p>