Horje
how to find and replace all the punctuation in python strings Code Example
how to find and replace all the punctuation in python strings
#import the regex library (pip install it with -> "pip install regex"
import re

test_phrase = 'This is a string! Bust it has punctuation. How can we remove it?'

#We're going to replace the punctution with a whitespace
clean = ' '.join(re.findall('[^!.?]+', test_phrase))
#         						^ Place the punctuation that you want
#								  to remove in the square brackets.
print(clean)
> 'This is a string But it has punctuation How can we remove it'




Python

Related
python time.strptime milliseconds Code Example python time.strptime milliseconds Code Example
discord.py make command admin only Code Example discord.py make command admin only Code Example
pytest --clrear cache Code Example pytest --clrear cache Code Example
download python on wsl Code Example download python on wsl Code Example
install python on windows subsystem for linux Code Example install python on windows subsystem for linux Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7