Bug in Python Regex? (re.sub with re.MULTILINE)

Use

re.sub(pattern, replace, text, flags=re.MULTILINE) 

instead of

re.sub(pattern, replace, text, re.MULTILINE) 

which is equivalent to

re.sub(pattern, replace, text, count=re.MULTILINE)

which is a bug in your code.

See re.sub()

Leave a Comment