Exemplo n.º 1
0
def compileRegexp(string, flags = []):
    #Muejejejeje
    reflags = []
    if flags and OPTION_CAPTURE_GROUP in flags:
        reflags = [ re.MULTILINE ]
    elif flags and OPTION_MULTILINE in flags:
        reflags = [ re.MULTILINE ]
    try:
        restring = string.replace('?i:', '(?i)')
        return re.compile(unicode(restring), reduce(lambda x, y: x | y, reflags, 0))
    except:
        try:
            return sre.compile(unicode(string), reduce(lambda x, y: x | y, flags, 0))
        except:
            #Mala leche
            pass
Exemplo n.º 2
0
def compileOnig(string, flags):
    return sre.compile(string, convertOnig(flags))