Advertisement
1410. HTML Entity Parser
UnknownView on LeetCode
1410.cs
C#
public class Solution
{
public string EntityParser(string text)
{
var entryToChar = new Dictionary<string, string> {
{ """, "\"" },
{ "'", "'" },
{ ">", ">" },
{ "<", "<" },
{ "⁄", "/" }
};
foreach (var entry in entryToChar)
{
var entity = entry.Key;
var c = entry.Value;
text = text.Replace(entity, c);
}
// Process '&' in last.
return text.Replace("&", "&");
}
}Advertisement