Course of Raku / Regexes and grammars / Regexes / Literals and character classes / Exercises / The first non-digit

Solution: The first non-digit

Here is a possible solution to the task.

Code

say '42abc' ~~ /\D/;

🦋 You can find the source code in the file first-non-digit.raku.

Output

「a」

Comments

  1. \D is the opposite of \d: it matches any character that is not a digit.

  2. The first two characters are digits, so the match starts at a.

Course navigation

The first non-digit   |   Matching strings