Course of Raku / Regexes and grammars / Regexes / Quantifiers / Star, plus, and question mark
Quiz — Basic quantifiers
What does the following program print? Note the *
quantifier on the a.
say 'br' ~~ / b a* r /;| 1 | 「br」 |
| 0 | 「bar」 |
| 0 | False |
| 0 | 「b」 |
* means “zero or more”, so a* is happy to
match no a at all. In br there is no
a between the b and the r, but
the pattern still matches because zero repetitions are allowed, giving
「br」.