title: NodeJS REGEX: Efficient Regex Search for multiple keywords?
body: <p>I have a search now that iterates over each json object that I have and each keyword. I want to match this search exclusive, not inclusive and I'm guessing I will need more robust regex. Basically, test true if the string contains ALL of the keywords. (order does not matter)</p>
  
  <p>Searching for "This Text" would <strong>include the following results:</strong></p>
  
  <p>"this text", "this is a text", "This Text", "Text This", "this is a long string and text", "a long string with this in the middle and text", "that this that this text"</p>
  
  <p><strong>and negate text similar to the following strings:</strong></p>
  
  <p>"that text", "this is not", "text that is not included"</p>
  
  <p>Here's the script I have right now.</p>
  
  <pre><code>items.forEach(function(item) { //iterate over the items array
      var s = JSON.stringify(item); //convert each item in items to a string
      var matched = false;
      sarray.forEach(function(qs) { //take the toArray converted query and iterate over it
          var r = new RegExp(qs, "g"); //compose a regex object with the stringified query
          if(r.test(s)) { //if regex finds the keyword in the item string,
              matched = true; //set matched to true
          }
      });
      if(matched) {
          results.push(item); //push the item into the results array
      }
  </code></pre>