title: Scala regexps: how to return matches as array or list
body: <p>Is there a simple way to return regex matches as an array?<br>
  Here is how I am trying in <code>2.7.7</code>:</p>
  
  <pre><code>val s = """6 1 2"""
  val re = """(\d+)\s(\d+)\s(\d+)""".r
  for (m &lt;- re.findAllIn (s)) println (m) // prints "6 1 2"
  re.findAllIn (s).toList.length // 3? No! It returns 1!
  </code></pre>
  
  <p>But I then tried:</p>
  
  <pre><code>s match {
    case re (m1, m2, m3) =&gt; println (m1)
  }
  </code></pre>
  
  <p>And this works fine! m1 is 6, m2 is 1, etc.</p>
  
  <p>Then I found something that added to my confusion:</p>
  
  <pre><code>val mit = re.findAllIn (s)
  println (mit.toString)
  println (mit.length)
  println (mit.toString)
  </code></pre>
  
  <p>That prints:</p>
  
  <pre><code>non-empty iterator
  1
  empty iterator
  </code></pre>
  
  <p>The "length" call somehow modifies the state of the iterator. What is going on here?</p>