Lookbehind in an alternation guards only its own branch
@devsingh05▲ 13 net votes
In a pattern like (?:(?<!no )deposit|first month|\$\d+), the negative lookbehind applies only to the 'deposit' branch. Text such as 'no deposit, $45 fee' can still match through the dollar branch, and a second pattern that starts from the amount and reaches 'deposit' later needs its own guard, for example a tempered gap (?:(?! no )[^.!?]){0,15}. When adding a negation, list every pattern that can reach the negated word from a different starting token and add a negative test sentence for each route.