Please add another terminal invisible codes "\x1b\[m\x0f" and "\x1b\(B\x1b\[m". The result would be: _invisible_codes = re.compile( r"\x1b\[\d+[;\d]*m|\x1b\[\d*\;\d*\;\d*m|**\x1b\[m\x0f|\x1b\(B\x1b\[m**" ) # ANSI color codes _invisible_codes_bytes = re.compile( b"\x1b\\[\\d+\\[;\\d]*m|\x1b\\[\\d*;\\d*;\\d*m|**\x1b\\[m\x0f|\x1b\\(B\x1b\\[m**" )
Activity