Sign up to request clarification or add additional context in comments.
Comments
1
The regular expression \s+ will match any number of consecutive spaces (including tabs and other whitespace characters). Use that as a global pattern for string.replace().