I am familiar with greedy and lazy quantifiers, but I was surprised to learn from this answer that there is a lazy equivalent for "exact number of matches":
+-------------------+-----------------+------------------------------+
| Greedy quantifier | Lazy quantifier | Description |
+-------------------+-----------------+------------------------------+
| {n} | {n}? | Quantifier: exactly n |
+-------------------+-----------------+------------------------------+
How could {n}
and {n}?
be different? I looked up the description in Microsoft's documentation and in their example for {n}?
(which is different from their example for {n}
), they explain:
[previous group]{2}? Match the pattern in the first group two times,
but as few times as possible.
From my studies in mathematics, the smallest value of two that I am aware of is two. Am I missing something?