Regex to trim a url to the last folder -


If I have a URL: (or more depth)

I want to trim it final Folder:

I also wish that there is no folder, then it must pass: (i.e. :) will not just be unattached, but still matches.

url.match (/ http: // [\ w.] + (?: / [^ /] + /)? /);

Comments