#1410
HTML Entity Parser
specialist · 925 · lc medium +32 · failed · 50.3% accepted · 214 likes · top 38%
Description
Implement an HTML entity parser that replaces the following encoded entities in the input string text with their actual characters:
- Quotation Mark: the entity is " and symbol character is ".
- Single Quote Mark: the entity is ' and symbol character is '.
- Ampersand: the entity is & and symbol character is &.
- Greater Than Sign: the entity is > and symbol character is >.
- Less Than Sign: the entity is < and symbol character is <.
- Slash: the entity is ⁄ and symbol character is /.
Return the decoded string.
Example 1:
Input: text = "& is an HTML entity but &ambassador; is not."
Output: "& is an HTML entity but &ambassador; is not."
Explanation: The parser will replace the & entity by &
Example 2:
Input: text = "and I quote: "...""
Output: "and I quote: \"...\""
Code
1
2
3