Skip to content

Practice HTML Entity Parser

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1410
LeetCode Problem

HTML Entity Parser

Problem Statement

Parse text by replacing these six HTML entities with their characters: " becomes a double quote, ' a single quote, & an ampersand, > a greater-than sign, < a less-than sign, and ⁄ a forward slash. Return the resulting text, leaving other input unchanged.

Source: HTML Entity Parser on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
text = "& is an HTML entity but &ambassador; is not."
Output
"& is an HTML entity but &ambassador; is not."

# Example 2

Input
text = "and I quote: "...""
Output
"and I quote: \"...\""

Constraints

1 <= text.length <= 10^5
The string may contain any possible characters out of all the 256 ASCII characters.

Related LeetCode Problems

Practice more problems similar to HTML Entity Parser.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.