[Python] Stack solution
We need to iterate right-to-left when doing the replacement in order to avoid a recursive replacement (ex. "&amp;amp;" -> "&amp;"). Before we check for a match 
We need to iterate right-to-left when doing the replacement in order to avoid a recursive replacement (ex. `"&amp;amp;"` -> `"&amp;"`). Before we check for a match by popping off the stack we make sure that we have seen the beginning of a sequence to ensure this works for cases like: `"&amp"` as well.\n```\nclass Solution:\n    def entityParser(self, text):\n        END = \'&\'\n        START = \';\'\n        d = {\n            \'&quot;\': \'"\',\n            \'&apos;\': "\'",\n            \'&amp;\': \'&\',\n            \'&gt;\': \'>\',\n            \'&lt;\': \'<\',\n            \'&frasl;\': \'/\',\n        }\n        stack = []\n        seen_start = False\n        for ch in reversed(text):\n            if ch == START:\n                seen_start = True\n            stack.append(ch)\n            if ch == END and seen_start:\n                # check for a match\n                temp = []\n                while stack[-1] != START:\n                    temp.append(stack.pop())\n                temp.append(stack.pop()) # the ;\n                val = \'\'.join(temp)\n                if val in d:\n                    stack.append(d[val])\n                else:\n                    stack.append(val)\n                seen_start = False\n        return \'\'.join(reversed(stack))\n```\t\t
['Stack', 'Python', 'Python3']