0

I have over 5000 lines like so:

www.example.com/de/germany/germany-company-domaincheck
www.example.com/de/germany/germany-company-question
www.example.com/de/germany/index
www.example.com/de/germany-page
www.example.com/de/france/france-company-domaincheck
www.example.com/de/france/france-company-question
www.example.com/de/france/index
www.example.com/de/france/france-page

I need to replace:

www.example.com/de/germany/germany-company-domaincheck
www.example.com/de/france/france-company-domaincheck
etc

With

www.example.com/de/enquiry

Unfortunately I am useless at regular expressions and don't know where to start. Using sublime text what is the correct regular expression to find all occurrences of /?/?-company-domaincheck

1
  • Getting from zero to a point where you can match /?/?-company-domaincheck with regular expressions would take you a few hours of reading introduction level how-tos at most. So this question is basically telling us that you don't want to do that. That's ... not a good starting point, really. Commented Oct 30, 2014 at 17:22

1 Answer 1

2

The regex

/(www\.example\.com)(\/\w+){3}(-company-domaincheck)/g

will match any of

www.example.com/?/?/?-company-domaincheck

(assuming that ? only contains [A-Za-z]), as in your examples.

To match another number of folders in between, replace {3} by the desired number (or by + for any).

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

2 Comments

You need to escape the dots. And the parens are unnecessary except for the repeated group.
+1 for "escape dots". Thanks, edited my answer. Although parentheses are unnecessary, they make the regex look more clean (in my point of view).

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.