This is basically another find-and-replace type of program, like swapping all the numbers in a string in chapter 4 or all the vowels in a string in chapter 8. We wrote those programs using very manual, imperative methods, like iterating through all the characters of a string, comparing them to some wanted value, and possibly returning a new value.
In the final solution for chapter 8, we briefly touched on “regular expressions” (also called “regexes”--pronounced with a soft “g” like in “George”), which give us a declarative way to describe patterns of text. The material here may seem a bit of a reach, but I really want to help you dig into regexes to see what they can do.