def _id_regexps_function(input_string, context): ret = [] for regexp in context.get('id_regexps'): for match in RePattern(regexp, children=True).matches(input_string, context): ret.append(match.span) return ret
def expected_title(input_string, context): """ Expected title functional pattern. :param input_string: :type input_string: :param context: :type context: :return: :rtype: """ ret = [] for search in context.get('expected_title'): if search.startswith('re:'): search = search[3:] search = search.replace(' ', '-') matches = RePattern(search, abbreviations=[dash], flags=re.IGNORECASE).matches( input_string, context) for match in matches: ret.append(match.span) else: for start in find_all(input_string, search, ignore_case=True): ret.append((start, start + len(search))) return ret