Course of Raku / Regexes and grammars / Regexes / Literals and character classes / Exercises / A vowel

Solution: A vowel

Here is a possible solution to the task.

Code

say 'Hello' ~~ / <[aeiou]> /;

🦋 You can find the source code in the file a-vowel.raku.

Output

「e」

Comments

  1. The class <[aeiou]> lists the five vowels; it matches whichever one appears first.

  2. In Hello, the letter H is not in the class, so the match starts at e.

Course navigation

A vowel   |   The first non-digit