Course of Raku / Regexes and grammars / Regexes

Quantifiers

So far every part of a pattern matched exactly one character. A quantifier says how many times the preceding piece may repeat: zero or more, one or more, an exact number, and so on.

Quantifiers are what let a regex match a whole word, a run of digits, or an optional piece that may or may not be there. This section covers the three basic quantifiers, the general ** quantifier, and the difference between greedy and frugal matching.

Topics in this section

Practice

Complete the quizzes that cover the contents of this section.

Exercises

This section contains 4 exercises. Examine all the topics of this section before doing the coding practice.

  1. An optional sign
  2. Two to four digits
  3. A frugal match
  4. Two to four

Course navigation

Solution: Where is the digit   |   Star, plus, and question mark