title: Javascript dynamic regex
body: <p>After looking here I came up with a patter to test an array of words against a string.</p>
  
  <pre><code>$.each(data, function(index, val) {
      var pattern = new RegExp('?:^|\s'+ val + '?=\s|$', 'g');
      console.log(pattern.test(comment));
      if (!pattern.test(comment)) {                           
             yay = true;
           }
  });
  </code></pre>
  
  <p>the problem here is that it returns true all the time. Any suggestions? Thanks!</p>