possessive method
Makes this pattern possessive
Possessive quantifiers are like greedy quantifiers, but they never backtrack. Once they match, they keep what they matched even if this causes the overall pattern to fail. This can improve performance but may prevent some matches that would succeed with greedy or lazy quantifiers.
Can only be applied to quantified patterns (created with optional() or repeat()).
Implementation
Pattern possessive() {
if (_node is! nodes.Quantifier) {
throw STRlingError(
'Pattern.possessive(): Can only make quantified patterns possessive. '
'Use optional() or repeat() first.');
}
final quant = _node as nodes.Quantifier;
return Pattern._(
nodes.Quantifier(
target: quant.target,
min: quant.min,
max: quant.max,
greedy: true,
lazy: false,
possessive: true,
),
namedGroups: _namedGroups,
);
}