0

I want to match the following URL

/root/folder/123

without the /root in front of it. I was trying around with this pattern ((?!root).)*$ which I found in this answer: https://stackoverflow.com/a/406408/237312

but it doesn't work either, because it still matches oot/folder/123. I thought about something like (?!(root)+.)*$ which matches nothing, so I'm looking for an answer here.

2
  • Do you want to match the URL but return everything without /root or do you want to match URLs like this if they do not start wit /root? Commented Nov 5, 2012 at 10:51
  • I want to match URLs starting with /rootin front, but I don't want to match it. Kev's asnwer is exactly what I was looking for. Commented Nov 5, 2012 at 10:55

2 Answers 2

2

You can use lookbehind syntax: (?<=...)

For example:

(?<=/root).*$

It'll match /folder/123.

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

Comments

1

You could do this:

\/root(.+)

The first group, i.e., $1 will be /folder/123

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.