import re r = re.compile(r"((x|yz)+?(t)??c)*") match = r.match('xtcxyzxc') # this is the group (t), which is matched once but is not returned here print repr(match.group(3)) # its span just looks strange print match.span(3)