Course of Raku / Regexes and grammars / Grammars / What is a grammar / Named regexes
Quiz — Named regexes
What does the following program print?
my regex letter { <[a..z]> }
'a1' ~~ / <letter> /;
say $<letter>;| 1 | 「a」 |
| 0 | 「1」 |
| 0 | 「a1」 |
| 0 | 「letter」 |
Calling a named regex as <letter> both matches it
and captures the result under that name. The pattern finds the first
lowercase letter, a, so $<letter> is
「a」.