title: Perl Regex match lines that contain multiple words
body: <p>I am trying to develop a rather fast full text search. It will read the index, and should ideally run the matching in just one regex.</p>
  
  <p>Therefore, I need a regex that matches lines only if certain words are contained.</p>
  
  <p>E.g. for</p>
  
  <pre><code>my $txt="one two three four five\n".
          "two three four\n".
          "this is just a one two three test\n";
  </code></pre>
  
  <p>Only line one and three should be matched, since line two does not contain the word "one".</p>
  
  <p>Now I could go through each line in a while() or use multiple regexes, but I need my solution to be fast.</p>
  
  <p>The example from here:
  <a href="http://www.regular-expressions.info/completelines.html" rel="nofollow">http://www.regular-expressions.info/completelines.html</a>
  ("Finding Lines Containing or Not Containing Certain Words")</p>
  
  <p>is what I need. However, I can't get it to work in Perl. I tried a lot, but it just doesn't come up with any result.</p>
  
  <pre><code>my $txt="one two three four five\ntwo three four\nthis is just a one two three test\n";
  my @matches=($txt=~/^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$/gi);
  print join("\n",@matches);
  </code></pre>
  
  <p>Gives no output.</p>
  
  <p>In summary:
  I need a regex to match lines containing multiple words, and returning these whole lines.</p>
  
  <p>Thanks in advance for your help! I tried so much, but just don't get it to work.</p>