Raku-Kurs / Reguläre Ausdrücke und Grammatiken / Reguläre Ausdrücke / Captures / Positionelle Captures
Quiz — Positionelle Captures
Was gibt das folgende Programm aus?
if 'ab-cd' ~~ / (\w+) '-' (\w+) / {
say $1;
}| 0 | 「ab」 |
| 1 | 「cd」 |
| 0 | 「ab-cd」 |
| 0 | 「-」 |
Die beiden Klammerpaare capturen in $0 und
$1, ab null nummeriert. Das erste capturt ab,
das zweite capturt cd, $1 ist also
「cd」.