Python REGEX simple solution but its slow and takes up more memory
Python REGEX solution. I know there are faster methods but the first thing that came to mind while reading about this problem was REGEX and this is how I tackle
Python REGEX solution. I know there are faster methods but the first thing that came to mind while reading about this problem was REGEX and this is how I tackled the problem. \n\ndashrepl function is called whenever a match is found and based on "thisdict" it returns the needed value. \n```\nimport re\n\nthisdict = {\n    "&quot;": "\\"",\n    "&apos;": "\\\'",\n    "&amp;": "&",\n    "&gt;": ">",\n    "&lt;": "<",\n    "&frasl;": "/" \n}\n\ndef dashrepl(matchobj):\n        if matchobj.group(0) in thisdict:\n            return thisdict.get(matchobj.group(0))\n        else:\n            return matchobj.group(0)\n\nclass Solution(object):\n    def entityParser(self, text):\n        regex = re.compile(r"&[a-zA-Z]+;", re.S)\n        \n        myfile2 = regex.sub(dashrepl, text)\n\n        return myfile2\n\nx = Solution()\n\nprint(x.entityParser("&amp; is an HTML entity but &ambassador; is not."))\n```
['Python']