lazy method
Makes this pattern lazy (non-greedy)
Lazy quantifiers match as few characters as possible, unlike greedy
quantifiers which match as many as possible. For example, a.*?b
(lazy) matches the shortest string starting with 'a' and ending with 'b',
while a.*b (greedy) matches the longest such string.
Can only be applied to quantified patterns (created with optional() or repeat()).
Implementation
Pattern lazy() {
if (_node is! nodes.Quantifier) {
throw STRlingError(
'Pattern.lazy(): Can only make quantified patterns lazy. '
'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: false,
lazy: true,
possessive: false,
),
namedGroups: _namedGroups,
);
}