Course of Raku / Regexes and grammars / Regexes / Quantifiers / Exercises / Two to four
Solution: Two to four
Here is a possible solution to the task.
Code
say 'abcdef' ~~ / \w ** 2..4 /;🦋 You can find the source code in the file range-quantifier.raku.
Output
「abcd」Comments
\w ** 2..4matches from two to four word characters.Being greedy, it takes as many as the range allows — four — so the match is
abcd.
Course navigation
← Two to four | Captures →