import re def strip_colors(str=None): str = re.sub(r'\^x\w\w\w', '', str) str = re.sub(r'\^\d', '', str) return str def html_colors(str=None): orig = str str = re.sub(r'\^x(\w)(\w)(\w)', "", str) str = re.sub(r'\^1', "", str) str = re.sub(r'\^2', "", str) str = re.sub(r'\^3', "", str) str = re.sub(r'\^4', "", str) str = re.sub(r'\^5', "", str) str = re.sub(r'\^6', "", str) str = re.sub(r'\^7', "", str) str = re.sub(r'\^8', "", str) str = re.sub(r'\^9', "", str) str = re.sub(r'\^0', "", str) for span in range(len(re.findall(r'\^x\w\w\w|\^\d', orig))): str += "" return str