Course of Raku / Regexes and grammars / Grammars / What is a grammar / Exercises

Reuse a token

Problem

Declare a named regex word that matches one or more word characters. Use it twice in one pattern to match two words separated by a space, as in 'cat dog'. Print both captured words, each on its own line.

Example

The program prints:

「cat」
「dog」

Solution

See the solution

Course navigation

Solution: A named token   |   Solution: Reuse a token