def find_char_color(ansi_string, pos):
    """Determine what color a character is in the string.

    :param str ansi_string: String with color codes (ANSI escape sequences).
    :param int pos: Position of the character in the ansi_string.

    :return: Character along with all surrounding color codes.
    :rtype: str
    """
    result = list()
    position = 0  # Set to None when character is found.
    for item in (i for i in RE_SPLIT.split(ansi_string) if i):
        if RE_SPLIT.match(item):
            result.append(item)
            if position is not None:
                position += len(item)
        elif position is not None:
            for char in item:
                if position == pos:
                    result.append(char)
                    position = None
                    break
                position += 1
    return ''.join(result)
def find_char_color ( ansi_string , pos ) : result = list ( ) position = 0 for item in ( i for i in RE_SPLIT . split ( ansi_string ) if i ) : if RE_SPLIT . match ( item ) : result . append ( item ) if position is not None : position += len ( item ) elif position is not None : for char in item : if position == pos : result . append ( char ) position = None break position += 1 return '' . join ( result )
Determine what color a character is in the string.

    :param str ansi_string: String with color codes (ANSI escape sequences).
    :param int pos: Position of the character in the ansi_string.

    :return: Character along with all surrounding color codes.
    :rtype: str