Why doesn’t ignorecase flag (re.I) work in re.sub() [duplicate]

Seems to me that you should be doing:

import re
print(re.sub('class', 'function', 'Class object', flags=re.I))

Without this, the re.I argument is passed to the count argument.

Leave a Comment