def compile(pattern, flags=None, alphabet=None, engine=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 if isinstance(pattern, str): hint_alphabet = Ascii() elif isinstance(pattern, unicode): hint_alphabet = Unicode() else: hint_alphabet = None pattern = RegexObject(parse_pattern(pattern, engine, flags=flags, alphabet=alphabet, hint_alphabet=hint_alphabet), pattern, engine=engine) return pattern
def parse(self, regexp, flags=0, alphabet=None): return parse_pattern(regexp, self.default_engine(), alphabet=alphabet if alphabet else self._alphabet, flags=flags)
def parse(pattern, replacement): (state, _graph) = parse_pattern(pattern, BaseEngine) return parse_replace(replacement, state)
def parse(pattern, flags=0): return parse_pattern(pattern, BaseEngine, flags=flags)
def parse(pattern, engine=BaseEngine, flags=0): return parse_pattern(pattern, engine, flags=flags)