Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
def parse(pattern, flags=0):
    return parse_pattern(pattern, BaseMatchEngine, flags=flags)
Exemple #4
0
def parse(pattern, engine=BaseMatchEngine, flags=0):
    return parse_pattern(pattern, engine, flags=flags)
Exemple #5
0
def parse(pattern, replacement):
    (state, _graph) = parse_pattern(pattern, BaseMatchEngine)
    return parse_replace(replacement, state)
Exemple #6
0
 def parse(self, regexp, flags=0, alphabet=None):
     return parse_pattern(regexp, self.default_engine(),
                          alphabet=alphabet if alphabet else self._alphabet, 
                          flags=flags)