title: javascript - insert a variable into regexp
body: <p>I have the following which works fine, allowing a form field to be valid if blank or containing the word "hello" or passing the other validation...</p>
  
  <pre><code>var re = new RegExp(/^$|^[hello]|^([FG]?\d{5}|\d{5}[AB])$/);
  </code></pre>
  
  <p>but I want to make the word "hello" be the value of a variable.</p>
  
  <p>I have tried this but it no longer seems to work:</p>
  
  <pre><code>var i = "hello";
  var re = new RegExp('/^$|^['+i+']|^([FG]?\d{5}|\d{5}[AB])$/');
  </code></pre>