Course of Raku / Regexes and grammars / Grammars / Tokens and rules / Exercises

Regex versus token

Problem

Show the difference backtracking makes. Declare the same pattern — one or more digits followed by a literal 5 — twice: once as a regex and once as a token. Match each against '12345' and print a plain True or False for each.

Example

The program prints:

True
False

Solution

See the solution

Course navigation

Quiz — Tokens and rules   |   Solution: Regex versus token