title: passing variable in regular expression in javascript for string match
body: <p>Suppose i need to use string match in javascript to get a result equivalent to the LIKE operator.</p>
  
  <pre><code>WHERE "str1" LIKE '%str2%';
  </code></pre>
  
  <p>The below match expression works.</p>
  
  <pre><code>var str1="abcd/pqrst"; 
  var str2 =  "pqr";
  
  if(str1.match(/^.*pqr.*/)){ //do something};
  </code></pre>
  
  <p>But i need to pass a variable instead of pqr, something like the below statement.Please help.</p>
  
  <pre><code>//Wrong
  var re = new RegExp("/^.*"+ str2 + ".*/"); 
  if(str1.match(re){ //do something}
  </code></pre>