Assert that something does NOT precede
(?<!...) is the negative form of lookbehind: "at this position, the pattern inside does NOT match the text before." Match succeeds only if the lookbehind pattern would fail.
The most common use: skip references to escaped or commented-out content
"Find every TODO comment that is NOT prefixed with 'DONE-'." The negative lookbehind asserts the unwanted prefix is absent. Without it, you'd match everything and filter in code.
Real example: sentence-boundary detection
Pattern: (?<!Mr|Mrs|Dr)\.\s+[A-Z] — a period followed by space and capital letter, but only if it's NOT preceded by a title abbreviation. Sloppy sentence boundaries usually trip on 'Mr. Smith said' being treated as two sentences. Negative lookbehind fixes that.
Same width restrictions as positive lookbehind
Python re wants fixed-width here too. The pattern (?<!Mr|Mrs|Dr) has alternatives of different widths (2, 3, 2) — Python's built-in re may raise an error on this. Solutions: install regex module, OR pad to fixed width by repeating, OR rethink as positive matching with later filtering.
Interaction with anchors
(?<!^) means "not at the start of the string." Combined with anchors, lookbehind unlocks position-sensitive patterns: "find this token but not at the very start of the line," "find quotes that aren't at the very start."