import re some_re = re.compile(r""" (?Pabc) (?P (?(abc)yes|noo) ) """, re.VERBOSE)