Is it possible to use only a regex (no additional code!) for matching the nth match? For example:
“CAR” – “TRAIN” – “BOAT” – “BICYCLE”
Now I only want to match the BOAT, regex for matching would be “[A-Z]+” however this also matches the first, second and fourth.
Does anyone have a pure regex solution for this? I need this because I can’t change the code that uses the regex, but I can provide a regex.
Best regards,
Robin
I think this lookbehind should do it:
It matches a word that comes two words after the start of the string