In Python, I can compile a regular expression to be case-insensitive using re.compile
:
>>> s = 'TeSt'
>>> casesensitive = re.compile('test')
>>> ignorecase = re.compile('test', re.IGNORECASE)
>>>
>>> print casesensitive.match(s)
None
>>> print ignorecase.match(s)
<_sre.SRE_Match object at 0x02F0B608>
Is there a way to do the same, but without using re.compile
. I can't find anything like perl's i
suffic (e.g. m/test/i
) in the documentation.
This is somewhat related to my previous question Is it worth using Python’s re.compile? but different enough to ask separately.