def compile(pattern, flags=None, alphabet=None, engine=None, factory=None): require_engine(engine) if isinstance(pattern, RegexObject): if flags is not None and flags != pattern.flags: raise ValueError('Changed flags') if alphabet is not None and alphabet != pattern.alphabet: raise ValueError('Changed alphabet') else: if flags is None: flags = 0 pattern = RegexObject(parse_pattern(pattern, engine, flags=flags, alphabet=alphabet), pattern=pattern, engine=engine, factory=factory) return pattern
def parse(pattern, flags=0): return parse_pattern(pattern, BaseMatchEngine, flags=flags)
def parse(pattern, engine=BaseMatchEngine, flags=0): return parse_pattern(pattern, engine, flags=flags)
def parse(pattern, replacement): (state, _graph) = parse_pattern(pattern, BaseMatchEngine) return parse_replace(replacement, state)
def parse(self, regexp, flags=0, alphabet=None): return parse_pattern(regexp, self.default_engine(), alphabet=alphabet if alphabet else self._alphabet, flags=flags)