Chrome Extension

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)
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
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?
0 Comments
Join Devsheet Ask a Question