Python regex re.sub : something
python, regex
Solution
Update - In Python 2.6 you can just 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 the count(number of replacements to make) and `re.IGNORECASE` is simply an integer so it is using that as the count.
>>> re.sub(';','.',x, flags=re.IGNORECASE)
'aaaaaaaa.aa.aaa.aaa.aaaaaaaaaa.'
>>> re.IGNORECASE
2
Problem
I have a program like this : ``` import re x='aaaaaaaa;aa;aaa;aaa;aaaaaaaaaa;' x=re.sub(';','.',x, re.IGNORECASE) print x ``` But the output is like this: ``` aaaaaaaa.aa.aaa;aaa;aaaaaaaaaa; ``` There are still some `;` not replaced by a `.`, why ? Using Python 2.6