With one simple line of code you can take a string and remove all extra spaces between words/characters, so there is only one space between words and characters. At the same time, trim both ends of the string to remove spaces or padding at the beginning and end of the string.