I would like to match 10 characters after the second pattern:
My String:
www.mysite.de/ep/3423141549/ep/B104RHWZZZ?something
What I want to be matched:
B104RHWZZZ
What the regex currently matches:
B104RHWZZZ?something
Currently, my Regex looks like this:
(?<=\/ep\/)(?:(?!\/ep\/).)*$.
Could someone help me to change the regex that it only matches 10 characters after the second "/ep/" ("B104RHWZZZ")?
>Solution :
It depends on which characters you allow to match. If you want to allow 10 non whitspace characters characters not being / or ? then you could use;
(?<=\/ep\/)[^\/?\s]{10}(?=[^\/\s]*$)
Explanation
(?<=\/ep\/)Assert/ep/directly to the left[^\/?\s]{10}Match 10 times any non whitespace character except for/and?(?=[^\/\s]*$)Assert no more occurrence of/to the right
Or matching 1+ chars other than / ? & instead of exactly 10:
(?<=\/ep\/)[^\/?&\s]+(?=[^\/\s]*$)