[issue42871] Regex compilation crashed if I change order of alternatives under quantifier
Matthew Barnett
report at bugs.python.org
Fri Jan 8 21:38:37 EST 2021
Matthew Barnett <python at mrabarnett.plus.com> added the comment:
Example 1:
((a)|b\2)*
^^^ Group 2
((a)|b\2)*
^^ Reference to group 2
The reference refers backwards to the group.
Example 2:
(b\2|(a))*
^^^ Group 2
(b\2|(a))*
^^ Reference to group 2
The reference refers forwards to the group.
As I said, the re module doesn't support forward references to groups.
If you have a regex where forward references are unavoidable, try the 3rd-party 'regex' module instead. It's available on PyPI.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42871>
_______________________________________
More information about the Python-bugs-list
mailing list