Python sol by replace and regex. 85%+ [w/ Hint ]
Python sol by replacement.\n\n---\n\nHint:\n\nRemeber to put the & replacement on the last one, in order to avoid chain reaction replacement.\n\nFor example: \n
Python sol by replacement.\n\n---\n\n**Hint**:\n\nRemeber to put the & replacement on the last one, in order to avoid chain reaction replacement.\n\nFor example: \n![image](https://assets.leetcode.com/users/brianchiang_tw/image_1586670638.png)should be ![image](https://assets.leetcode.com/users/brianchiang_tw/image_1586670724.png), instead of ">"\n\n---\n\n**Implementation** by string replacement:\n\n```\nclass Solution:\n    def entityParser(self, text: str) -> str:\n        \n        html_symbol = [ \'&quot;\', \'&apos;\', \'&gt;\', \'&lt;\', \'&frasl;\', \'&amp;\']\n        formal_symbol = [ \'"\', "\'", \'>\', \'<\', \'/\', \'&\']\n                \n        for html_sym, formal_sym in zip(html_symbol, formal_symbol):\n            text = text.replace( html_sym , formal_sym )\n        \n        return text\n        \n```\n\n---\n\n**Implementation** by regular expression:\n\n```\nimport re\nclass Solution:\n    def entityParser(self, text: str) -> str:\n        \n        html_symbol = [ \'&quot;\', \'&apos;\', \'&gt;\', \'&lt;\', \'&frasl;\', \'&amp;\']\n        formal_symbol = [ \'"\', "\'", \'>\', \'<\', \'/\', \'&\']\n                \n        for html_sym, formal_sym in zip(html_symbol, formal_symbol):\n            text = re.sub( html_sym , formal_sym, text )\n        \n        return text\n```\n\n---\n\n\nReference:\n\n[1] [Python official docs about str.replace( ... )](https://docs.python.org/3/library/stdtypes.html#str.replace)\n\n[2] [Python official docs about re.sub( ... )](https://docs.python.org/3/library/re.html#re.sub)\n\n---\n\nRelated leetcode challenge:\n\n[Leetcode #1108 Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address/)
['String', 'Python', 'Python3']