Class Solution

java.lang.Object
g1401_1500.s1410_html_entity_parser.Solution

public class Solution extends Object
1410 - HTML Entity Parser.<p>Medium</p> <p><strong>HTML entity parser</strong> is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.</p> <p>The special characters and their entities for HTML are:</p> <ul> <li><strong>Quotation Mark:</strong> the entity is <code>&quot;</code> and symbol character is <code>&quot;</code>.</li> <li><strong>Single Quote Mark:</strong> the entity is <code>&apos;</code> and symbol character is <code>'</code>.</li> <li><strong>Ampersand:</strong> the entity is <code>&amp;</code> and symbol character is <code>&</code>.</li> <li><strong>Greater Than Sign:</strong> the entity is <code>&gt;</code> and symbol character is <code>></code>.</li> <li><strong>Less Than Sign:</strong> the entity is <code>&lt;</code> and symbol character is <code><</code>.</li> <li><strong>Slash:</strong> the entity is <code>&frasl;</code> and symbol character is <code>/</code>.</li> </ul> <p>Given the input <code>text</code> string to the HTML parser, you have to implement the entity parser.</p> <p>Return <em>the text after replacing the entities by the special characters</em>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> text = &ldquo;&amp; is an HTML entity but &ambassador; is not.&rdquo;</p> <p><strong>Output:</strong> &ldquo;& is an HTML entity but &ambassador; is not.&rdquo;</p> <p><strong>Explanation:</strong> The parser will replace the &amp; entity by &</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> text = &ldquo;and I quote: &quot;&hellip;&quot;&rdquo;</p> <p><strong>Output:</strong> &ldquo;and I quote: \&rdquo;&hellip;\&quot;&quot;</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= text.length <= 10<sup>5</sup></code></li> <li>The string may contain any possible characters out of all the 256 ASCII characters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details