JGuizard
6/17/2016 - 8:44 AM

Regular expression in Python

Regular expression in Python

import re

#Match any word
wre = re.compile('\w')
wre.sub(' ','This. Is, A, Text{}')  #Replace any word with an empty strijng

#Match everything that is not a word
notwre = re.compile('[^\w]')
notwre.sub('','This. Is, A, Text{}')