Write like this
import re
pattern = re.compile(r'world') #<-regex
match = pattern.search('Hello world!')
if match:
print 'match string is', match.group()
else:
print 'match string not found'
#->match string is world
Recommended Posts