python
Python - regex , remove all single characters,replace all single chars,char
# remove all single characters
# replace all single chars,char
import re
text = "That is a test for removing multiple spaces"
document = re.sub(r's+[a-zA-Z]s+', ' ', text)
print(document)
Output
That is test for removing multiple spaces
Remove all single characters with Space that we specify in regex expression
Was this helpful?
Similar Posts
- Python - regex,replace all character exept A-Z a-z and numbers
- Python - regex , replace multiple spaces with one space
- Convert multiple spaces of a string to single space in python [with and without regex]
- Python - String ,remove,delete,replace,extract numbers from string
- Replace all spaces with hyphens in Python
- Convert all string characters to lowercase in python
- Python code to validate email address using regex