Nenad
Nenad

Reputation: 3566

Match all after hostname

How can I match all that comes after a hostname. If I have:

    http://test.someweb.net/category/subcategory/?some=value

I want to match:

    /category/subcategory/?some=value

Upvotes: 0

Views: 268

Answers (2)

James Kyburz
James Kyburz

Reputation: 14503

url = "http://asjahsjahsjahs.ashags.asjahs/andbcb/c/d"

m = url.match(/https?:\/\/[^\/]*(\/.*)/);

m[1] ; //# =>  /andbcb/c/d 

Upvotes: 0

Gabi Purcaru
Gabi Purcaru

Reputation: 31564

/http:\/\/[^/]+(.*)/

The first matched group ((.*)) is the one you need.

Upvotes: 2

Related Questions