def CompileRegex(regex, options): regex = IFF(options.name, lambda: Library(regex), regex) if options.removeanchor: regex = IFF(regex.startswith('^'), regex[1:], regex) regex = IFF(regex.endswith('$'), regex[:-1], regex) regex = IFF(options.boundary, '\\b%s\\b' % regex, regex) try: oREExtra = reextra.cREExtra(regex, IFF(options.casesensitive, 0, re.IGNORECASE) + IFF(options.dotall, 0, re.DOTALL), options.sensical) except: raise Exception('Error regex: %s' % regex) return regex, oREExtra
def CompileRegex(regex, options): regex = IFF(options.name, lambda: Library(regex), regex) if options.removeanchor: regex = IFF(regex.startswith('^'), regex[1:], regex) regex = IFF(regex.endswith('$'), regex[:-1], regex) regex = IFF(options.boundary, '\\b%s\\b' % regex, regex) try: oREExtra = reextra.cREExtra(regex, IFF(options.casesensitive, 0, re.IGNORECASE) + IFF(options.dotall, 0, re.DOTALL), options.sensical) except: raise Exception('Error regex: %s' % regex) return regex, oREExtra