import rem = re.match('foo', 'foo') # pattern matches stringif m is not None: # show match if successful m.group()