title: Take first non-empty regex.exec() capturing group
body: <p>Let's say I run this</p>
  
  <pre><code>var text = "abc def ghi";
  var regex = /a(bc)|d(e)f|(gh)i/g
  while (match = regex.exec(text)) {
    console.log(match);
  }
  // 0=abc, 1=bc, 2=undefined, 3=undefined
  // 0=def, 1=undefined, 2=e, 3=undefined
  // 0=ghi, 1=undefined, 2=undefined, 3=gh
  </code></pre>
  
  <p>In every iteration of the loop, I'd like to retrieve the matching capturing group, so only bc, e, gh. Is it possible without manually checking for undefined?</p>