Course of Raku / Regexes and grammars / Regexes / Lookaround assertions / Exercises

A bare number

Problem

The string '5 and $9' contains two numbers: a plain 5 and a price $9. Using a negative lookbehind, write a pattern that matches a number only when it is not immediately preceded by a $. Print the match.

Example

The program prints:

「5」

Solution

See the solution

Course navigation

Quiz — Assertions   |   Solution: A bare number