'Returns a translator that calls re.sub() on the query with the given
search and replace arguments.'

@classmethod
def make_regexp_translator(cls, search_re, replace_str):

    def translator(query):
        return re.sub(search_re, replace_str, query)
    return translator
