Open this example in the interactive library
Source code
import re
print(re.sub(r'\s+', ' ', 'one two three'))Sample output
one two three

Replace repeated whitespace. A self-contained example using the Python standard library.
Open this example in the interactive library
import re
print(re.sub(r'\s+', ' ', 'one two three'))one two three