[issue41555] re.sub replaces twice

2020-09-05 Thread S. Zhang
S. Zhang added the comment: Thanks. On Mon, Aug 17, 2020 at 7:40 PM Pablo Galindo Salgado < rep...@bugs.python.org> wrote: > > Change by Pablo Galindo Salgado : > > > -- > resolution: -> not a bug > stage: -> resolved > status: open -> closed > >

[issue41555] re.sub replaces twice

2020-08-17 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue41555] re.sub replaces twice

2020-08-15 Thread S. Zhang
S. Zhang added the comment: Okay. Thanks. On Sat, Aug 15, 2020 at 9:07 AM Ma Lin wrote: > > Ma Lin added the comment: > > There can be at most one empty match at a position. IIRC, Perl's regex > engine has very similar behavior. > If don't want empty match, use + is fine. > > -- >

[issue41555] re.sub replaces twice

2020-08-15 Thread Ma Lin
Ma Lin added the comment: There can be at most one empty match at a position. IIRC, Perl's regex engine has very similar behavior. If don't want empty match, use + is fine. -- ___ Python tracker ___

[issue41555] re.sub replaces twice

2020-08-15 Thread S. Zhang
S. Zhang added the comment: Thanks. But if talking about empty matches, there would be endless empty matches at the end in such cases. So in my opinion, [^\.]*$ should match txt plus the empty match because the greedy rule applies here. On Fri, Aug 14, 2020 at 10:37 PM Ma Lin wrote: > > M

[issue41555] re.sub replaces twice

2020-08-14 Thread Ma Lin
Ma Lin added the comment: The re.sub() doc said: Changed in version 3.7: Empty matches for the pattern are replaced when adjacent to a previous non-empty match. IMO 3.7+ behavior is more reasonable, and it fixed a bug, see issue25054. -- nosy: +malin

[issue41555] re.sub replaces twice

2020-08-14 Thread S. Zhang
New submission from S. Zhang : The following command produced "name.tsvtsv" with version 3.7.1 and 3.8.5 instead of the expected "name.tsv" from version 2.7.5, 3.5.6, and 3.6.7. Changing * to + produced expected "name.tsv". python -c 'import re; v="name.txt";v = re.sub("[^\.]*$", "tsv", v);p