[issue41605] t = re.sub(".*", "*", src) has different ouput
Ronald Oussoren
report at bugs.python.org
Fri Aug 21 11:48:35 EDT 2020
Ronald Oussoren <ronaldoussoren at mac.com> added the comment:
in 3.6 t == '*', in 3.7 and later it is '**'.
To be honest I don't like the 3.7 behaviour, it is very surprising even if it is technically correct (the first '*' is from a match from the entire string, the second one is from an empty match at the end of the string).
A workaround is to explicitly anchor the regular expression (for example by adding '^' to the start).
----------
nosy: +ronaldoussoren
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41605>
_______________________________________
More information about the Python-bugs-list
mailing list