I want to match everything in a URL up to the last section.
So I want to match: http://www.test.com/one/two/
in all of the following cases:
http://www.test.com/one/two/three
http://www.test.com/one/two/three/
http://www.test.com/one/two/three/?foo=bar
I'm working in PHP and currently I have /.+\/(?=[^\/]+\/?$)/
this matches everything except the last case but I can't seem to 'not match a forward slash unless it's followed by a question mark' which would seeming sort the problem?