If you are replacing all occurrences of commas with backslashes, then you should use str.replace instead of re.sub. Replace will be much faster.
I am also wondering about the choice of backslash. My concern is that it could be misinterpreted as an escape in some situations. In particular, backslashes could easily get stripped or misinterpreted in search expressions.
|