#### ? designates an optional group. It can appear once or not at all RegEx = re.compile(r'(good)?bye') mo = RegEx.search("bye bye bye") mo.group()