I have a url 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 or continue with a "/" and more url text. I'd like to match urls like this:
- http://server/xyz/2008-10-08-4
- http://server/xyz/2008-10-08-4/
- http://server/xyz/2008-10-08-4/123/more
But not match something like this:
So, I thought my best bet was something like this:
/(.+)/(\d{4}-\d{2}-\d{2})-(\d+)[/$]
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?