```cpp class Solution { public: string entityParser(string text) { unordered_map<string, char> HashMap{ {"&quot;", '\"'}, {"&apos;", '\''}, {"&amp;", '&'}, {"&gt;", '>'}, {"&lt;", '<'}, {"&frasl;", '/'} }; string result; for(auto i{0}; i< text.size();i++) { //如果当前字符不是'&',就直接添加到结果字符串中 if(text[i] != '&'){ result += text[i]; continue; } auto sub_str = text.substr(i, 7); auto found = false; for (auto [key, value]: HashMap) { //如果找到了对应的实体字符,就添加对应的字符到结果字符串中 if (sub_str.find(key) == 0) { result += value; i += key.size() - 1; found = true; break; } } //如果没有找到对应的实体字符,就直接添加'&' if(!found) result += text[i]; } return result; } }; ```