title: Regular expression matches an extra empty group
body: <p>I'm new to the domain of regular expressions.<br>
  All I'll post below are simplified examples from my code.</p>
  
  <p>I have a string, let's say <code>test_1,some_2,foo,bar_4,</code> that I want to replace by <code>title: test (1) title: some (2) title: foo () title: bar (4)</code></p>
  
  <p>What I have now is (which works):</p>
  
  <pre><code>var test = "test_1,some_2,foo,bar_4,";
  console.log(test.replace(/(.*?)(?:_(\d))?,/g, "title: $1 ($2)\n"));
  </code></pre>
  
  <p>which outputs:</p>
  
  <pre><code>title: test (1)
  title: some (2)
  title: foo ()
  title: bar (4)
  </code></pre>
  
  <p>In an effort to makes things right, I want to get rid off the coma after the last item. The list will look like <code>test_1,some_2,foo,bar_4</code> <strong>(no coma after bar_4)</strong></p>
  
  <p>So the new code:</p>
  
  <pre><code>var test = "test_1,some_2,foo,bar_4";
  console.log(test.replace(/(.*?)(?:_(\d))?(?:,|$)/g, "title: $1 ($2) "));
  </code></pre>
  
  <p>outputs something wrong. There's an extra empty match at the end:</p>
  
  <pre><code>title: test (1)
  title: some (2)
  title: foo ()
  title: bar (4)
  title:  ()
  </code></pre>
  
  <p>My questions are: Why? How to fix it? Is there any possible improvements in the actual regex?</p>
  
  <p><strong><a href="http://jsfiddle.net/xPt3U/" rel="nofollow" title="demo jsFiddle">demo jsFiddle</a></strong></p>