Course of Raku / Regexes and grammars / Grammars / The parse tree, make and made / Exercises
Extract the number
Problem
Write a grammar that matches a weight like '5kg' — a
number (one or more digits) followed by the literal unit
kg. Using an inline make, attach just
the numeric value as a real integer, dropping the unit. Parse
'5kg' and print the result of .made.
Example
The program prints:
5