python
Python - regex , replace multiple spaces with one space
# Substituting multiple spaces with single space
# replace multiple spaces with one space
# delete spaces
# spaces delete
# tabs replace with one space
# tow ore more spaces betwen words
import re
text = "That is a test for removing multiple spaces"
document = re.sub(r's+', ' ', text, flags=re.I)
print(document)
Output
That is a test for removing multiple spaces
Substituting multiple spaces with single space replace multiple spaces with one space delete spaces delete tabs replace with one space tow ore more spaces between wordsÂ
Was this helpful?
Similar Posts
- Convert multiple spaces of a string to single space in python [with and without regex]
- Replace all spaces with hyphens in Python
- Python - regex,replace all character exept A-Z a-z and numbers
- Python - regex , remove all single characters,replace all single chars,char
- Delete one or multiple columns from Pandas Dataframe
- Trim or remove begin and end spaces from a python string
- One line code to get the sum of a list in python