text = 'UPPER PYTHON, lower python, Mixed Python' re.findall('python', text, flags=re.IGNORECASE) ['PYTHON', 'python', 'Python'] re.sub('python', 'snake', text, flags=re.IGNORECASE) 'UPPER snake, lower snake, Mixed snake'