示例#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
示例#2
0
文件: base.py 项目: diegomvh/regexp
def compileOnig(string, flags):
    return sre.compile(string, convertOnig(flags))