Course of Raku / Regexes and grammars / Regexes / Captures / Positional captures

Quiz — Positional captures

What does the following program print?

if 'ab-cd' ~~ / (\w+) '-' (\w+) / {
    say $1;
}
0「ab」
1「cd」
0「ab-cd」
0「-」

The two pairs of brackets capture into $0 and $1, numbered from zero. The first captures ab, the second captures cd, so $1 is 「cd」.

Course navigation

Positional captures   |   Named captures