IT/Python

python re sub remove special characters

Jang HyunWoong 2022. 11. 17. 08:03
# remove special characters
corpus = "learning% makes 'me' happy. i am happy be-cause i am learning! :)"
corpus = re.sub(r"[^a-zA-Z0-9.?! ]+", "", corpus)
print(corpus)
learning makes me happy. i am happy because i am learning! 

 

반응형