Course of Raku / Regexes and grammars / Regexes / Anchors / Word boundaries
Quiz — Anchors
What does the following program print?
say so 'I have a dog' ~~ /<< dog >>/;| 1 | True |
| 0 | False |
| 0 | 「dog」 |
| 0 | Nil |
The pattern requires dog to be a whole word. In
I have a dog, dog stands alone with a space
before it and the end of the string after it, so there is a word
boundary on each side, the match succeeds, and so returns
True.
Course navigation
← Word boundaries | Starts with →