Negative look ahead can be used to negate specific words using regex, i.e., to match something is not followed by something else.

Example: Search for “Card Number” and return the number except when ending comes after “Card Number”.

Situation 1: “card number 111111111111111”

Situation 2: “card number ending in 1841”

KV Extraction Configuration

Key Pattern: [C,c]ard [N,n]umber (?!ending)

Value Pattern: \d{2,16}

Location: RIGHT

No of words: 0

Further you can also use negative look behind to match that something is not following something else, i.e., to match ending is not present before card number you can use following key pattern : Key Pattern:

(?<!ending) Card Number|(?<!ending) card number

Example: Capture “Date” but not “Due Date”

Value Pattern: ([^(Due)]+\s+Date)

Was this article helpful to you?

J.D. Abbey

Comments are closed.