I've a problem with my regex in Python.
et
may only match if it is not preceded by m
or mme
string: M et Mme Du Pont
or Mme et M Du Pont
regex: '\b(?<!m|mme)\bet\b'
error: look-behind requires fixed-with patterd
How can i fix this?
'\b(?<!m)(?<!mme)\bet\b'
doesn't seem to work either
Apart from the error, there is a space in the example data after
m
andmme
which is missing in the pattern.Another option is to use the regex PyPi module with a single lookbehind asserting what is directly at the left is
m
, optionally followed byme
and followed by a space.Regex demo | Python using regex module demo
For example
Output