Course of Raku / Regexes and grammars / Regexes / Quantifiers / Greedy and frugal matching
Quiz — Quantifiers
What does the following program print?
say 'aaaa' ~~ / a ** 2..3 /;| 0 | 「aa」 |
| 1 | 「aaa」 |
| 0 | 「aaaa」 |
| 0 | False |
The quantifier ** 2..3 allows two or three repetitions
and, being greedy, takes as many as it can — three. The fourth
a is left unmatched.