user2132188
user2132188

Reputation: 177

Notepad ++ Regex replace

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

Answers (3)

Bentoy13
Bentoy13

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

Jerry
Jerry

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

user1129665
user1129665

Reputation:

Try to replace directly /\w+\.html with nothing.

Upvotes: 1

Related Questions