Update. In Python 2.6, you can simply do this:
>>> re.sub('(?i);','.',x)
'aaaaaaaa.aa.aaa.aaa.aaaaaaaaaa.'
For Python 2.7+ and 3.0+
Do this instead, the third parameter is actually a counter (the number of changes to replace), and re.IGNORECASEis just an integer, so it is used as a counter.
>>> re.sub(';','.',x, flags=re.IGNORECASE)
'aaaaaaaa.aa.aaa.aaa.aaaaaaaaaa.'
>>> re.IGNORECASE
2
source
share