Click here to Skip to main content
15,746,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I need regex help.

I have this url (for example)

I want to identify if the second folder contains 'en' (true or false)

How do I do that with regex?

What I have tried:




path rx:\/[\w]{2}$
Updated 24-May-21 6:20am


If the regex matches, the second folder is "en". If it doesn't, it isn't.

If you are going to work with regular expressions, then get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.
Share this answer
Assuming your using extended POSIX, you were very nearly there with the first example posted: The following seems to work for me:
If you want to capture the 2nd path element, then the following sed extended POSIX regex also works
sed -E -e "s/https?:\/\/[^/]+?\/[^/]+\/([^/]+)\/.*/\1/"
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900