Negative Lookahead Assertion

from blog Susam Pal, | ↗ original
↗ original
Here is an example of negative lookahead assertion in regular expression using Python: import re strings = ['foo', 'bar', 'baz', 'foo-bar', 'bar-baz', 'baz-foo'] matches = [s for s in strings if re.search('^(?!.*foo)', s)] print(matches) The regular expression ^(?!.*foo) in the above example matches strings that do not contain the pattern...