nzaleski nzaleski - 5 months ago 61
Perl Question

Negative Lookahead RegEx

Why is this not working? Trying to do a negative lookahead. I am trying to pull the numbers from the bins, except in quarantine bin and inspection bin. When I do the code with the ^ in the front is matches all numbers in parenthesis. When I remove the ^ it matches nothing.

Also can you use the "or operator |" inside the negative lookahead? I want to have ^(?!Quarantine_Bin|Inspection_Bin)

I also tried to specifically negate

and it is still matching.





You should be using a negative lookbehind as:


RegEx Demo

(?<!(Quarantine|Inspection)_Bin) is a negative lookbehind that asserts failure if there is Quarantine_Bin or Inspection_Bin before our match.