Possible re bug when using ".*"
Alexander Richert - NOAA Affiliate
alexander.richert at noaa.gov
Wed Dec 28 13:42:29 EST 2022
In a couple recent versions of Python (including 3.8 and 3.10), the
following code:
import re
print(re.sub(".*", "replacement", "pattern"))
yields the output "replacementreplacement".
This behavior does not occur in 3.6.
Which behavior is the desired one? Perhaps relatedly, I noticed that even
in 3.6, the code
print(re.findall(".*","pattern"))
yields ['pattern',''] which is not what I was expecting.
Thanks,
Alex Richert
--
Alexander Richert, PhD
*RedLine Performance Systems*
More information about the Python-list
mailing list