title: "AND" in Javascript regex... what am I missing?
body: <p>I am working on a regex which would return true if matched words are present in any order.</p>
  
  <p>This approach (discussed here: <a href="https://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator">Regular Expressions: Is there an AND operator?</a>)</p>
  
  <pre><code>(?=.*tag1)(?=.*tag2)
  </code></pre>
  
  <p>matches both <code>tag1 tag2</code> and <code>tag2 tag1</code> (<a href="http://rubular.com/r/374706hkft" rel="nofollow noreferrer">http://rubular.com/r/374706hkft</a>), in Ruby, but <em>does not work</em> in JavaScript. Any ideas?</p>
  
  <p>Edit: by "Does not work in JS" I meant that </p>
  
  <pre><code>"tag1 tag2".match(/(?=.*tag1)(?=.*tag2)/) 
  </code></pre>
  
  <p>returns <code>[""]</code>.</p>
  
  <p>The answer to this question pointed out that the regex works in the format of </p>
  
  <pre><code>/(?=.*tag1)(?=.*tag2)/.test("tag1 tag2")
  </code></pre>