title: How to capture an arbitrary number of groups in JavaScript Regexp?
body: <p>I would expect this line of JavaScript:</p>
  
  <pre><code>"foo bar baz".match(/^(\s*\w+)+$/)
  </code></pre>
  
  <p>to return something like:</p>
  
  <pre><code>["foo bar baz", "foo", " bar", " baz"]
  </code></pre>
  
  <p>but instead it returns only the last captured match:</p>
  
  <pre><code>["foo bar baz", " baz"]
  </code></pre>
  
  <p>Is there a way to get all the captured matches?</p>