This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mrabarnett
Recipients LewisGaul, abacabadabacaba, ezio.melotti, jacksonriley, malin, mrabarnett, serhiy.storchaka
Date 2019-11-05.00:48:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1572914884.25.0.398287333528.issue23692@roundup.psfhosted.org>
In-reply-to
Content
It's been many years since I looked at the code, and there have been changes since then, so some of the details might not be correct.

As to have it should behave:

re.match('(?:()|(?(1)()|z)){1,2}(?(2)a|z)', 'a')

Iteration 1.
Match the repeated part. Group 1 matches.
Iteration 2.
Match the repeated part. Group 1 matches.
Has group 2 matched? No.
Try to match 'z'. Fail and backtrack.
Retry the repeated part.
Iteration 2.
Has group 1 matched? Yes.
Group 2 matches.
Has group 2 matched? Yes.
Try to match 'a'. Success. Group 1 matched and group 2 matched.


re.match('(?:()|(?(1)()|z)){1,2}(?(1)a|z)', 'a')

Iteration 1.
Match the repeated part. Group 1 matches.
Iteration 2.
Match the repeated part. Group 1 matches.
Has group 1 matched? Yes.
Try to match 'a'. Success. Group 1 matched and group 2 didn't match.
History
Date User Action Args
2019-11-05 00:48:04mrabarnettsetrecipients: + mrabarnett, ezio.melotti, abacabadabacaba, serhiy.storchaka, malin, LewisGaul, jacksonriley
2019-11-05 00:48:04mrabarnettsetmessageid: <1572914884.25.0.398287333528.issue23692@roundup.psfhosted.org>
2019-11-05 00:48:04mrabarnettlinkissue23692 messages
2019-11-05 00:48:04mrabarnettcreate