Description
Where
https://perldoc.perl.org/perlre#Quantifiers :
Note that the possessive quantifier modifier can not be combined with the non-greedy modifier. This is because it would make no sense. Consider the follow equivalency table:
Illegal Legal
------------ ------
X??+ X{0}
X+?+ X{1}
X{min,max}?+ X{min}
Description
Take for example X = (?:a|ab)
, then
"abc" =~ m/^(?:(?:a|ab){1,2}?)c/
- matches (i.e. "abc" =~ m/^(?:a|ab){1}c/
- matches)
"abc" =~ m/^(?>(?:a|ab){1,2}?)c/
- doesn't
(later one which is atomic is equivalent to illegal m/^(?:a|ab){1,2}?+c/
)
Atomic/possessive locks backtracking, so it seems to reduce to X{min}+
rather than X{min}
. Or alternatively - (?>X{min})
.
If any of alternative inside regex is a prefix of later alternative (despite it looks redundant), then later may be skipped, which should have matched with m/X{min}/
.