Introduction
Use sub and gsub to change parts of text by replacing words or characters.
You want to fix a typo in a sentence.
You need to change all spaces to dashes in a string.
You want to replace only the first occurrence of a word.
You want to remove unwanted characters from text.
You want to update a format, like changing dates from slashes to dashes.