Re: [Python-Dev] Zero-width matching in regexes

2017-12-13 Thread Serhiy Storchaka
05.12.17 01:21, MRAB пише: I've finally come to a conclusion as to what the "correct" behaviour of zero-width matches should be: """always return the first match, but never a zero-width match that is joined to a previous zero-width match""". If it's about to return a zero-width match that's jo

Re: [Python-Dev] Zero-width matching in regexes

2017-12-06 Thread Serhiy Storchaka
06.12.17 15:37, Paul Moore пише: Behaviour (1) means that we'd get >>> regex.sub(r'\w*', 'x', 'hello world', flags=regex.VERSION1) 'xx xx' (because \w* matches the empty string after each word, as well as each word itself). I just tested in Perl, and that is indeed what happens there as well.

Re: [Python-Dev] Zero-width matching in regexes

2017-12-06 Thread Paul Moore
On 6 December 2017 at 13:13, Serhiy Storchaka wrote: > 05.12.17 22:26, Terry Reedy пише: >> >> On 12/4/2017 6:21 PM, MRAB wrote: >>> >>> I've finally come to a conclusion as to what the "correct" behaviour of >>> zero-width matches should be: """always return the first match, but never a >>> zero-

Re: [Python-Dev] Zero-width matching in regexes

2017-12-06 Thread Serhiy Storchaka
05.12.17 22:26, Terry Reedy пише: On 12/4/2017 6:21 PM, MRAB wrote: I've finally come to a conclusion as to what the "correct" behaviour of zero-width matches should be: """always return the first match, but never a zero-width match that is joined to a previous zero-width match""". Is this d

Re: [Python-Dev] Zero-width matching in regexes

2017-12-06 Thread Serhiy Storchaka
05.12.17 01:21, MRAB пише: I've finally come to a conclusion as to what the "correct" behaviour of zero-width matches should be: """always return the first match, but never a zero-width match that is joined to a previous zero-width match""". If it's about to return a zero-width match that's jo

Re: [Python-Dev] Zero-width matching in regexes

2017-12-05 Thread MRAB
On 2017-12-05 20:26, Terry Reedy wrote: On 12/4/2017 6:21 PM, MRAB wrote: I've finally come to a conclusion as to what the "correct" behaviour of zero-width matches should be: """always return the first match, but never a zero-width match that is joined to a previous zero-width match""". Is t

Re: [Python-Dev] Zero-width matching in regexes

2017-12-05 Thread Terry Reedy
On 12/4/2017 6:21 PM, MRAB wrote: I've finally come to a conclusion as to what the "correct" behaviour of zero-width matches should be: """always return the first match, but never a zero-width match that is joined to a previous zero-width match""". Is this different from current re or regex?

[Python-Dev] Zero-width matching in regexes

2017-12-04 Thread MRAB
I've finally come to a conclusion as to what the "correct" behaviour of zero-width matches should be: """always return the first match, but never a zero-width match that is joined to a previous zero-width match""". If it's about to return a zero-width match that's joined to a previous zero-wid