Returns a case-insensitive regex for searching terms

def term_regex(term):
    """
    Returns a case-insensitive regex for searching terms
    """
    return re.compile(r'^{0}$'.format(re.escape(term)), re.IGNORECASE)