title: Regex to match URL end-of-line or "/" character
body: <p>I have a <a href="http://en.wikipedia.org/wiki/Uniform_resource_locator" rel="noreferrer">URL</a>, and I'm trying to match it to a regular expression to pull out some groups. The problem I'm having is that the URL can either end <em>or</em> continue with a "/" and more URL text. I'd like to match URLs like this:</p>
  
  <ul>
  <li><a href="http://server/xyz/2008-10-08-4" rel="noreferrer">http://server/xyz/2008-10-08-4</a></li>
  <li><a href="http://server/xyz/2008-10-08-4/" rel="noreferrer">http://server/xyz/2008-10-08-4/</a></li>
  <li><a href="http://server/xyz/2008-10-08-4/123/more" rel="noreferrer">http://server/xyz/2008-10-08-4/123/more</a></li>
  </ul>
  
  <p>But not match something like this:</p>
  
  <ul>
  <li><a href="http://server/xyz/2008-10-08-4-1" rel="noreferrer">http://server/xyz/2008-10-08-4-1</a></li>
  </ul>
  
  <p>So, I thought my best bet was something like this:  </p>
  
  <pre><code>/(.+)/(\d{4}-\d{2}-\d{2})-(\d+)[/$]
  </code></pre>
  
  <p>where the character class at the end contained either the "/" or the end-of-line. The character class doesn't seem to be happy with the "$" in there though. How can I best discriminate between these URLs while still pulling back the correct groups?</p>