title: Emulating SQL LIKE in JavaScript
body: <p>How can I emulate the SQL keyword <code>LIKE</code> in JavaScript?</p>
  
  <p>For those of you who don't know what <code>LIKE</code> is, it's a very simple regex which only supports the wildcards <code>%</code>, which matches 0 or more characters, and <code>_</code> which matches exactly one character.</p>
  
  <p>However, it's not just possible to do something like:</p>
  
  <pre><code>var match = new RegEx(likeExpr.replace("%", ".*").replace("_", ".")).exec(str) != null;
  </code></pre>
  
  <p>...because the pattern might contain dots, stars and any other special regex characters.</p>