When dealing with textual data, you may be required to find or replace words that follow a particular pattern. For…