def __len__(self):
        '''
        This ensures that you will always get the actual length of the string,
        minus the extended characters. Which is of course important, when you
        are calculating output field sizes. Requires the re module.
        '''
        tmp = self[:]
        cnt = 0
        for i in re.sub('\\x1b[\[0-9;]*m', '', tmp):
            cnt += 1
        return(cnt)

        This ensures that you will always get the actual length of the string,
        minus the extended characters. Which is of course important, when you
        are calculating output field sizes. Requires the re module.
        
recipes/Python/578908_PythAsciiColor_video/recipe-578908.py