We can pass re.IGNORECASE to the flags parameter of search, match, or sub −
Example
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))
Output
<_sre.SRE_Match object at 0x0000000005316648> <_sre.SRE_Match object at 0x0000000005316648> xxxxmeat