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

Initial and surname

Problem

The string 'J Smith' is an initial (a single letter), a space, and a surname. Using named captures called initial and surname, match the string and print the surname.

Example

The program prints:

Smith

Solution

See the solution

Course navigation

Solution: Last name first   |   Solution: Initial and surname