Say I have a string containing foobar fooBAR FOObar FOOBAR
, and I want to search all instances containing a case insensitive "foo" or "FOO" but a lowercase "bar". In this case, re.findall
should return ['foobar', 'FOObar']
.
The accepted answer for this question explains that it can be done in C# with (?i)foo(?-i)bar
, but Python raises an invalid expression error.
Does the Python regex library support such a feature?