title: Javascript: Wildcard regex search
body: <p>I need to filter an array of string with a wildcard regex:</p>
  
  <pre><code>// my search key
  var myKeyword = 'bar';
  
  // my search list
  var strings = ['foo', 'bar', 'foobar', 'barfoo', 'hello', 'java', 'script', 'javascript'];
  
  // my results
  var results = [];
  
  // the regexp, I don't understand
  var regex = new RegExp(\*/, myKeyword);
  
  // the for loop
  for (var i = 0; i &lt; strings.length; i++) {
      if (regex.test(strings[i]) {
          results.push(strings[i]);
      }
  }
  
  console.log(results); // prints ['bar', 'foobar', 'barfoo']
  </code></pre>
  
  <p>So how do I fix the regex?</p>