1410. HTML Entity Parser Medium
1/**
2 * [1410] HTML Entity Parser
3 *
4 * HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.
5 * The special characters and their entities for HTML are:
6 *
7 * Quotation Mark: the entity is " and symbol character is ".
8 * Single Quote Mark: the entity is ' and symbol character is '.
9 * Ampersand: the entity is & and symbol character is &.
10 * Greater Than Sign: the entity is > and symbol character is >.
11 * Less Than Sign: the entity is &lt; and symbol character is <.
12 * Slash: the entity is &frasl; and symbol character is /.
13 *
14 * Given the input text string to the HTML parser, you have to implement the entity parser.
15 * Return the text after replacing the entities by the special characters.
16 *
17 * Example 1:
18 *
19 * Input: text = "&amp; is an HTML entity but &ambassador; is not."
20 * Output: "& is an HTML entity but &ambassador; is not."
21 * Explanation: The parser will replace the &amp; entity by &
22 *
23 * Example 2:
24 *
25 * Input: text = "and I quote: &quot;...&quot;"
26 * Output: "and I quote: \"...\""
27 *
28 *
29 * Constraints:
30 *
31 * 1 <= text.length <= 10^5
32 * The string may contain any possible characters out of all the 256 ASCII characters.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/html-entity-parser/
38// discuss: https://leetcode.com/problems/html-entity-parser/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn entity_parser(text: String) -> String {
44 String::new()
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_1410() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.