Course of Raku / Regexes and grammars / Regexes / Lookaround assertions / Lookbehind
Quiz — Assertions
What does the following program print?
say 'a=5' ~~ / <?after '='> \d+ /;| 1 | 「5」 |
| 0 | 「=5」 |
| 0 | 「a=5」 |
| 0 | False |
The positive lookbehind <?after '='> requires an
= immediately before the current position, then
\d+ matches the digits. The = is checked but
not consumed, so the match is just 「5」.
Course navigation
← Lookbehind | A bare number →