title: Scala Regex Capturing on Positive Lookaheads
body: <p>I am attempting to use positive look-aheads to match on an arbitrary number of strings such that one can achieve the logic of 'foo' AND 'bar AND ... etc where the regex would match and on content that contained 'foo' and 'bar' and capture those occurrences in a given text blob. </p>
  
  <p>I am using positive look-aheads to allow for any ordering. And we do not care about the cases so I've made the matching case insensitive.</p>
  
  <p>An example regex is as follows:</p>
  
  <pre><code>(?i)(?=.*\b(foo)\b)(?=.*\b(bar)\b)
  </code></pre>
  
  <p>Now, while this appears to work in various testers (<a href="http://regex101.com" rel="nofollow">http://regex101.com</a>) it seems to fail in the following Scala code:</p>
  
  <pre><code>val regex = """(?i)(?=.*\b(foo)\b)(?=.*\b(bar)\b)""".r
  val results = regex.findAllIn("foo zinc bar")
  val resultsList = result.toList
  
  results ~ non-empty iterator
  resultsList ~ List()
  </code></pre>
  
  <p>So as it stands I've confirmed that the regex seems to be formed properly and captures on various testing apps and that Scala does indicate there was some sort of match, but generates no resulting captures.</p>
  
  <p>Any explanation as to why Scala seems to behave differently or any fixes would be appreciated.</p>