Course of Raku / Regexes and grammars / Regexes / Quantifiers / Exercises

Two to four digits

Problem

Using the ** quantifier with a range, write a pattern that matches between two and four digits in a row. Test it on 'abc12345' and print the match. Because the quantifier is greedy, it should take as many digits as the range allows.

Example

The program prints:

「1234」

Solution

See the solution

Course navigation

Solution: An optional sign   |   Solution: Two to four digits