python

Python - regex,replace all character exept A-Z a-z and numbers

# Remove all the special characters
# replace all character exept A-Z a-z
import re

text = "That is a # ; '' 2 45 6 ?/..,,, test for removing                         multiple spaces"

document = re.sub(r'W', ' ', text)

print(document) # as we can see this regex expresion do not remove numbers
Output
That is a 2 45 6 test for removing multiple spaces

As we can see this regex expression do not remove numbers 

Was this helpful?