I would like to use more than one flag with the re.findall
function. More specifically, I would like to use the IGNORECASE
and DOTALL
Yes, but you have to OR them together:
x = re.findall(pattern=r'CAT.+?END', string='Cat \n eND', flags=re.I | re.DOTALL)
Is there a way to use more than one flag ?
It wasn't mentioned, but you can use inline (?...) modifiers as well.
x = re.findall(r'(?si)CAT.+?END', 'Cat \n eND')
You can't put the flags within a tuple. Use the pipe character (OR operand) within your flags:
x = re.findall(r'CAT.+?END','Cat \n eND',flags=re.I | re.DOTALL)