I'm trying to write some regex that will allow me to do a negative lookbehind on a capture group so that I can extract possible references from emails. I need to know how to look behind from a certain point to the first white space. If a digit is found, I don't want the reference to be extracted.
I have got as far as shown below. I have 2 capture groups - 'PreRef' and 'Ref'. I don't want a 'Ref' match to be found if 'PreRef' contains a digit. What I've got so far only checks if the character immediately before the colon is a digit.
(?<PreRef>\S+)(?<![\d]):(?<Ref>\d{5})
A 'Ref' match of 12345 should be found here:
This is a reference:12345
But not here (there's a 5 in the word 'reference'):
This is not a ref5rence:12345