sourceExtract Help with Positive Lookbehind


I’m trying to use a positive lookbehind to extract the last 7 digits in this sequence:

Confirmation Code: GFXBSFXM171905197

I’m using sourceExtract with this as my target:

regex=(?<=Confirmation Code: \D{1,}\d{1,})\d{7}

Every variation of this that I run returns 7190519. I want to grab the last 7 digits, 1905197.

I can write it as: regex=(?<=Confirmation Code: \D{1,}\d{2})\d{7} and achieve this, but sometimes there are 8 digits instead of 9. I will always need the final 7.

Any suggestions? What am I doing wrong?


Just add \b it means word break.
(?<=Confirmation Code: \D{1,}\d{1,})\d{7}\b

btw it can look a little cleaner: (?<=Confirmation Code: \D+\d+)\d{7}\b
And I’d use \s for spaces. Sometimes without that it missed what I needed.
So finally I’d offer you:



Ahhh yes that worked perfectly! Thanks a million!