create a new paste
import re exp = re.compile(r'tu(m*)y') s='''scratch your tummy''' ## Does the full string match? match_obj = exp.match(s) print match_obj print 'The above should be None.' ## Does any of the string match? match_obj = exp.search(s) print match_obj print "Ooh! It is some non-None value." print match_obj.group(0) print "The above shows the part that matched, on the whole." print match_obj.group(1) print 'The above shows the 1st "captured" group (which is any number of m characters)'