Course of Raku / Addendum 🆕 / Types and text machines / Regexes and grammars / Exercises
Normalise whitespace
Problem
Clean up the following string so that leading and trailing spaces are gone and every internal gap is a single space. Print the result.
my $messy = ' too many spaces ';Example
The program prints:
too many spacesSolution
Course navigation
← Solution: Parse a date with named captures | Solution: Normalise whitespace →