Course of Raku / Regexes and grammars / Regexes

Matching strings

In the previous section you wrote patterns and tested them with the smartmatch operator ~~. This section looks more closely at what that operator gives you back: a match object that carries all the information about what was found and where.

You will also see the different ways of writing a regex, and how to ask the simple yes-or-no question “did the string match at all?”.

Topics in this section

Practice

Complete the quizzes that cover the contents of this section.

Exercises

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

  1. Did it match?
  2. The matched text
  3. Where is the digit

Course navigation

Solution: The first non-digit   |   The smartmatch operator