I'm struggling to find a rule which will match a date pattern (and only that pattern) in between two sets of optional strings - birthday/birth/bday/born
.
One or more of the strings must be present in the input before the date can be matched.
Would also need to be performed in a single Regex matching operation if possible. This is one of several expressions I need to run through a handler which expects only a single expression and no facility for additional logic.
Here's an example:
I was born on 01/01-2001
should match 01/01-2001
My bday was on 01-01-2001 which was the day I was born, obviously
should match 01-01-2001
01 01 2001 was my day of birth
should match 01 01 2001
Today’s date is 24/06/2018
should not match
So far I have this: (?<=.*born|birth|bday).*?([0-9]{2,4}[^A-Za-z0-9]+[0-9]{2,4}[^A-Za-z0-9]+[0-9]{2,4})
which works perfectly in matching the date if those strings are present before it. It doesn't match anything if I have those strings after the date.