title: How to validate dash-separated values using regex?
body: <p>I have a string with digits and separators.
  The digits may either be separated by a  <code>comma</code> or a <code>hyphen</code>. But there may never be two digits that are both separated by hyphens without a comma in between.</p>
  
  <p>Example:</p>
  
  <p>valid: <code>123,12,2,1-3,1,1-3,1</code></p>
  
  <p>invalid: <code>123,12,2,1-3,1,1-3-5,1</code></p>
  
  <p>I have a regex that almost works, except it does not detect those <code>1-3-5</code> invalid lines.</p>
  
  <p>How can I improve the following?</p>
  
  <pre><code>^([0-9])+((,|-)[0-9]+)*$
  </code></pre>