title: Regex to match a hyphen in a string 0 or 1 times
body: <p>I am trying to build a regex that will check to see if a string has a hyphen 0 or 1 times.</p>
  
  <p>So it would return the following strings as ok.</p>
  
  <pre><code>1-5
  1,3-5
  1,3
  </code></pre>
  
  <p>The following would be wrong.</p>
  
  <pre><code>1-3-5
  </code></pre>
  
  <p>I have tried the following, but it is fine with 1-3-5:</p>
  
  <pre><code>([^-]?-){0,1}[^-]
  </code></pre>