views:

167

answers:

1

Hello,

I may have URLs like:

and what I would like to do is to remove part before /foo/bar/, with regex which will work if I have IP/something, IP:PORT/something or DOMAIN/something

Tnx!

+1  A: 

If you have always absolute URLs (beginning with the URL scheme), try this:

url.replace(/^[^\/]*(?:\/[^\/]*){2}/, "")
Gumbo