You're pretty close :)
You just need to be sure that before matching what you're looking for (i.e: (\.[a-z]{2,4})/\d{5}
), you haven't met any /
since the beginning of the line.
I would suggest you to simply preppend ^[^\/]*\.
before your current regex.
Thus, the resulting regex would be:
^[^\/]*\.([a-z]{2,4})/\d{5}
How does it work?
^
asserts that this is the beginning of the tested String[^\/]*
accepts any sequence of characters that doesn't contain/
\.([a-z]{2,4})/\d{5}
is the pattern you want to match (a.
followed by 2 to 4 lowercase characters, then a/
and at least 5 digits).
Here is a permalink to a working example on regex101.
Cheers!