1

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?

2
  • Do you specifically want to remove the everything after the 5th / or the last part of the link? Commented Sep 2, 2013 at 9:00
  • I want to remove all after the 5th / Commented Sep 2, 2013 at 9:03

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

You can replace /[^/]+(\s+|$) with nothing. If you have to filter with hmtl files, just add the extension like this: /[^/]+\.html(\s+|$).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.