Negative look ahead

I am trying to use negative look ahead assertion. Trying to find “Received Date” when there is no “Payment” word ahead of it. Using the following Regex

((?!Payment) Received)(((\b(?:[A-Za-z]{3,9} \d{1,2}, \d{4})\b)|(\s?\d+/\d+/\d+))(?=(.*)?))

The above should not match “Received 02/12/2020” in “Payments Received 02/12/2020”. But it is matching. Can you please help?

Hi @A_Learner ,

I believe there must be a slight change in the Expression :

((?<!Payment(s)?\s*)Received)(((\b(?:[A-Za-z]{3,9} \d{1,2}, \d{4})\b)|(\s?\d+/\d+/\d+))(?=(.*)?))

As it should be a Negative Look behind not ahead.

1 Like

Thank you, @supermanPunch

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.