Ranjith Ranjith - 5 days ago 4x
Python Question

Matches whatever regular expression is not inside the parentheses

How can I match strings that are not inside a set of strings using python regular expressions?
Ex: set of strings ('/abc|/bcd')
I want to match any string other than that in the parentheses. That should be exact match.


Here's a fun one for you:


It uses a negative lookahead to ensure that the string being matched isn't one of the strings you don't want, then grabs whatever else is left.

Demo on Regex101