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/;| 1 | True |
| 0 | False |
| 0 | 「hello world」 |
| 0 | Nil |
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.