Course of Raku / Regexes and grammars / Regexes / Anchors / Start and end of string

Quiz — String anchors

What does the following program print? Note the $ at the end of the pattern.

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

The $ anchor requires the match to finish at the very end of the string. The string hello world does end with world, so the anchored pattern succeeds and so returns True.

Course navigation

Start and end of string   |   Word boundaries