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.

classification
Title: regex module fails with a quantified backref but succeeds with repeated backref
Type: behavior Stage: resolved
Components: Regular Expressions Versions: Python 3.8
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: Davidebyzero, ezio.melotti, mrabarnett, pxeger
Priority: normal Keywords:

Created on 2021-04-04 07:52 by Davidebyzero, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg390175 - (view) Author: David Ellsworth (Davidebyzero) Date: 2021-04-04 07:52
The regex /^((x*)\2{3}(?=\2$))*x$/ matches powers of 5 in unary, expressed as strings of "x" characters whose length is the number.

The following command line should print "1", but prints nothing:
python -c 'import regex; regex.match(r"^((x*)\2{3}(?=\2$))*x$", "x"*125) and print(1)'

However, this command does print "1":
python -c 'import regex; regex.match(r"^((x*)\2\2\2(?=\2$))*x$", "x"*125) and print(1)'

And so does this one:
python -c 'import re; re.match(r"^((x*)\2{3}(?=\2$))*x$", "x"*125) and print(1)'

The expression "\2\2\2" should behave exactly the same as "\2{3}", but in the "regex" module it does not.

Solving the following Code Golf Stack Exchange challenge is what led me to discover this bug:
https://codegolf.stackexchange.com/questions/211840/is-that-number-a-two-bit-number%ef%b8%8f/222792#222792
msg390177 - (view) Author: Patrick Reader (pxeger) * Date: 2021-04-04 08:17
The `regex` module is a third-party package, not part of the Python standard library. Please report issues here: https://bitbucket.org/mrabarnett/mrab-regex/issues
msg390180 - (view) Author: David Ellsworth (Davidebyzero) Date: 2021-04-04 08:49
Thanks, I didn't realize. I thought it was an official module that wasn't included as part of the main package due to being unfinished.

Reported the bug here: https://bitbucket.org/mrabarnett/mrab-regex/issues/408/regex-fails-with-a-quantified
History
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87892
2021-04-04 08:49:36Davidebyzerosetstatus: open -> closed
resolution: third party
messages: + msg390180

stage: resolved
2021-04-04 08:17:58pxegersetnosy: + pxeger
messages: + msg390177
2021-04-04 07:52:01Davidebyzerocreate