Solution: Regexp - select everything before the 3rd slash

Development | Programming languages

What would be the easiest regexp selecting all before the 3rd slash

I tried this:


But it does not work exactly as I would hope it would do. Whats more i dont know that it will work in Google Analytics (Filter Section)

No attachments

What you might do instead is ot repeat matching 2 times not a forward slash and then a forward slash.


See a regex demo

If you don't want to match ?# you could add that to the character class


About your pattern

This part of your pattern ([^\/?#]+){3} captures in a group matching 1+ times any character that is not in the character class but after that repetition takes no forward slash into account.

Then (?:.*?\/) will match any character non greedy followed by a forward slash.

on May 06th, 2019 (9:34 pm)
All coments
This solution has not been commented yet.
You must sign in to comment!! LOGIN
We use cookies to give you the best possible experience on our site. By continuing to use the site you agree to our use of cookies. Find out more Accept