Course of Raku / Regexes and grammars / Regexes / Literals and character classes / Character classes
Quiz — Custom classes
What does the following program print? The class is a negated one.
say 'abc123' ~~ / <-[a..z]> /;| 1 | 「1」 |
| 0 | 「a」 |
| 0 | 「abc」 |
| 0 | False |
The class <-[a..z]> matches a single character
that is not a lowercase letter. Scanning
abc123 from the left, the first three characters are
lowercase letters and are skipped; the first character that is not a
lowercase letter is the digit 1, so the match is
「1」.