def with_color_stripped(f):
    """
    A function decorator for applying to `len` or imitators thereof that strips
    ANSI color sequences from a string before passing it on.  If any color
    sequences are not followed by a reset sequence, an `UnterminatedColorError`
    is raised.
    """
    @wraps(f)
    def colored_len(s):
        s2 = re.sub(
            COLOR_BEGIN_RGX + '(.*?)' + COLOR_END_RGX,
            lambda m: re.sub(COLOR_BEGIN_RGX, '', m.group(1)),
            s,
        )
        if re.search(COLOR_BEGIN_RGX, s2):
            raise UnterminatedColorError(s)
        return f(re.sub(COLOR_END_RGX, '', s2))
    return colored_len