Reputation: 177
I want to convert
http://website.com/cat/movie/nameofmovie.html
to this
http://website.com/cat/movie
So I have tried [/].*(html)
But this applied from first /
char, Is there any way to specify 5th /
in the line?
Is there any method to inverse replace?
Upvotes: 1
Views: 91
Reputation: 4956
You can replace /[^/]+(\s+|$)
with nothing. If you have to filter with hmtl files, just add the extension like this: /[^/]+\.html(\s+|$)
.
Upvotes: 0
Reputation: 71538
If you want to specifically remove everything after the 5th /
and removing this 5th slash, you can use:
((?:[^/]*/[^/]*){4})/.*html
And replace with $1
.
If you want to remove the last part of the link with the last slash, you can use:
/[^/]+html
And here since you don't have any capturing group, leave the replace with box blank.
Upvotes: 4