Gotchas
When you want a flag like m, you need to include a count:
a = re.sub(f,r,0,re.M)
rather than just
a = re.sub(f,r,re.M)
as the latter takes the integer value of re.M and uses that as the replacement count.
When you want a flag like m, you need to include a count:
a = re.sub(f,r,0,re.M)
rather than just
a = re.sub(f,r,re.M)
as the latter takes the integer value of re.M and uses that as the replacement count.