I have found this interesting issue with re.sub:
import re
s = "This: is: a: string:"
print re.sub(r'\:', r'_', s, re.IGNORECASE)
>>>> This_ is_ a: string:
Notice how only the first two instances were replaced. It seems that adding the [implicit] argument name for flags fixes the issue.
import re
s = "This: is: a: string:"
print re.sub(r'\:', r'_', s, flags=re.IGNORECASE)
>>>> This_ is_ a_ string_
I was wondering if anyone could explain it or it is in fact a bug.
I've encountered this issue before with the missing argument name string
but never for flags
and with string it usually blows up.