Skip to content

Possessive quantifier matches where an ordinary quantifier doesn't #106052

Closed
@benrg

Description

@benrg
>>> import re
>>> re.fullmatch('(?:ab?c)*', 'a')
>>> re.fullmatch('(?:ab?c)*+', 'a')
<re.Match object; span=(0, 1), match='a'>
>>>

I'm not sure that I completely understand the behavior of the possessive quantifiers, but I think that if R* doesn't match a string then R*+ shouldn't match it, where R is any regex.

Versions tested:

3.12.0b3 (tags/v3.12.0b3:f992a60, Jun 20 2023, 12:25:40) [MSC v.1936 64 bit (AMD64)]
3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:30:09) [MSC v.1934 32 bit (Intel)]
3.11.4 (main, Jun 14 2023, 18:33:43) [GCC 10.2.1 20210110]

Linked PRs

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixestopic-regextype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions