Course of Raku / Regexes and grammars / Regexes / Captures / Exercises

Last name first

Problem

The string 'Grace Hopper' is a first name and a last name separated by a space. Capture each word, then print the name in Last, First order — last name, a comma and a space, then first name.

You do not need substitution for this — capture the words and print them with string interpolation.

Example

The program prints:

Hopper, Grace

Solution

See the solution

Course navigation

Solution: City and country   |   Solution: Last name first