Course of Raku / Regexes and grammars / Regexes / Alternations / Exercises / A size word

Solution: A size word

Here is a possible solution to the task.

Code

say 'a large pizza' ~~ / small | medium | large /;

🦋 You can find the source code in the file colour-word.raku.

Output

「large」

Comments

  1. The alternation lists three possibilities; the pattern matches whichever one is present in the string.

  2. Only large appears, so that is the match.

Course navigation

A size word   |   http or https