On Python 3.7 (tested on Windows 64 bits), the replacement of a string using the RegEx .*
gives the input string repeated twice!
On Python 3.7.2:
>>> import re
>>> re.sub(".*", "(replacement)", "sample text")
'(replacement)(replacement)'
On Python 3.6.4:
>>> import re
>>> re.sub(".*", "(replacement)", "sample text")
'(replacement)'
On Python 2.7.5 (32 bits):
>>> import re
>>> re.sub(".*", "(replacement)", "sample text")
'(replacement)'
What is wrong? How to fix that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…