Course of Raku / Regexes and grammars / Regexes / Adverbs / Significant whitespace

Quiz — Adverbs

What does the following program print? Note the :s adverb and the run of spaces in the text.

say so 'hello   world' ~~ /:s hello world/;
1True
0False
0「hello world」
0Nil

The :s adverb makes the space between hello and world in the pattern significant — it requires whitespace there. One or more spaces all count, so the run of three spaces in the text matches and the result is True. Without :s, the space in the pattern would be ignored and the pattern would look for helloworld.

Course navigation

Significant whitespace   |   Case-blind match