Re: Possible re bug when using ".*"

2023-01-01 Thread Peter J. Holzer
On 2022-12-28 19:07:06 +, MRAB wrote: > On 2022-12-28 18:42, Alexander Richert - NOAA Affiliate via Python-list > wrote: > > print(re.sub(".*", "replacement", "pattern")) > > yields the output "replacementreplacement". [...] > It's not a bug, it's a change in behaviour to bring it more into lin

Re: Possible re bug

2022-12-29 Thread Barry Scott
Please please fix you email client so that your replies stay with the emails you are replying to. Barry On 28/12/2022 19:09, Stefan Ram wrote: Alexander Richert writes: |print(re.findall(".*","pattern")) |yields ['pattern',''] which is not what I was expecting. The asterisk is "greedy", so

Re: Possible re bug when using ".*"

2022-12-28 Thread Ethan Furman
On 12/28/22 11:07, MRAB wrote: On 2022-12-28 18:42, Alexander Richert - NOAA Affiliate via Python-list wrote:   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".

Re: Possible re bug when using ".*"

2022-12-28 Thread MRAB
On 2022-12-28 18:42, Alexander Richert - NOAA Affiliate via Python-list wrote: 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

Re: Possible re bug when using ".*"

2022-12-28 Thread Roel Schroeven
Roel Schroeven schreef op 28/12/2022 om 19:59: Alexander Richert - NOAA Affiliate via Python-list schreef op 28/12/2022 om 19:42: 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 "repla

Re: Possible re bug when using ".*"

2022-12-28 Thread Roel Schroeven
Alexander Richert - NOAA Affiliate via Python-list schreef op 28/12/2022 om 19:42: 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 occu

Possible re bug when using ".*"

2022-12-28 Thread Alexander Richert - NOAA Affiliate via Python-list
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 i