52 – Case-insensitive regular expressions#
Regular expressions can start with the flag (?i), marking them as case-insensitive:
import re
print(re.match(r"hey", "HeY"))
# None
print(re.match(r"(?i)hey", "HeY"))
# <re.Match object; span=(0, 3), match='HeY'>