title: Regex to match a slug?
body: <p>I'm having trouble creating a Regex to match URL slugs (basically, alphanumeric "words" separated by <em>single</em> dashes)</p>
  
  <pre><code>this-is-an-example
  </code></pre>
  
  <p>I've come up with this Regex: <code>/[a-z0-9\-]+$/</code> and while it restricts the string to only alphanumerical characters and dashes, it still produces some false positives like these:</p>
  
  <pre><code>-example
  example-
  this-----is---an--example
  -
  </code></pre>
  
  <p>I'm quite bad with regular expressions, so any help would be appreciated.</p>