'compile the given regexp, cache the reg, and call match_reg().'

def match(self, regexp, flags=None):

    try:
        reg = _regexp_cache[(regexp, flags)]
    except KeyError:
        if flags:
            reg = re.compile(regexp, flags)
        else:
            reg = re.compile(regexp)
        _regexp_cache[(regexp, flags)] = reg
    return self.match_reg(reg)
