title: Matching comma-separated ranges with a regex
body: <p>I have a bunch of comma-separated ranges and single numbers like this:</p>
  
  <pre><code>100-200,300,400,100-200
  
  300,100-200,100-200,400
  
  300,400,100-200,100-200
  </code></pre>
  
  <p>How do I match these lines individually using a JavaScript regex? I tried <code>(\w*,\w*(-)\w*,\w*)</code>, which turned out to match only the second example line partially.</p>