Trying to replace patterns in a multiline string:
re.sub(pattern, replacement, string, re.M)
This does not replace all matches, because the fourth parameter is the number of matches to be replaced. The fix is
re.sub(pattern, replacement, string, flags=re.M)
No comments:
Post a Comment