def rstrip_wildcard(string, wildcard='%', escape='\\'):
    """Strip ending wildcard from string"""
    if not string:
        return string
    new_string = string.rstrip(wildcard)
    if new_string[-1] == escape:
        return string
    return new_string
