Regex to match 2 level deep URL and not 3 level deep (Google Analytics)
We can say "not the following characters" using [^...]
the ^
stands for "not". So to restrict the levels we can use [^/]
.
Here some examples:
Match /sport/something : ^/sport/[^/]+$
Has to start with / and then exactly 1 / has to follow: ^/[^/]+/[^/]+$
or ^(/[^/]+){2}$
Generalized for start with / and followed by 4 / at most: ^(/[^/]+){1,5}$