programming-examples/python/Regular_Expression/Remove everything except alphanumeric characters from a string.py

4 lines
121 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
import re
text1 = '**//Python Exercises// - 12. '
pattern = re.compile('[\W_]+')
print(pattern.sub('', text1))