Python 如何编写不带re.compile的Python不区分大小写的正则表达式?
我们可以将re.IGNORECASE传递给search、match或sub的标记参数 –
阅读更多:Python 教程
例子
import re
print (re.search('bush', 'BuSh', re.IGNORECASE))
print (re.match('bush', 'BuSh', re.IGNORECASE))
print (re.sub('bush', 'xxxx', 'Bushmeat', flags=re.IGNORECASE))
输出
<_sre.SRE_Match object at 0x0000000005316648>
<_sre.SRE_Match object at 0x0000000005316648>
xxxxmeat
极客教程