Reputation: 473
if I have a website like: www.google.com/en/my-page/anotherpage
how is it possible that with reg-ex to get: /en/my-page ? I am using this reg-ex in the IIS?
So far I have done something similar to this:
^(?:\\.|[^/\\])*/((?:\\.|[^/\\])*)/
but it is returning /en/my-page/ and I want it to return /en/my-page
Upvotes: 0
Views: 100
Reputation: 173642
You could use a look-ahead assertion to get rid of the last slash:
/\/.*(?=\/)/
Upvotes: 1
Reputation: 3154
In grep your regex is returning the string "www.google.com/en/". You can simply use the following regex if positive look behind is not mandatory :
(/[^/]+)+
Upvotes: 1