struct Solution;
impl Solution {
fn entity_parser(text: String) -> String {
text.replace(""", "\"")
.replace("'", "'")
.replace("⁄", "/")
.replace("<", "<")
.replace(">", ">")
.replace("&", "&")
}
}
#[test]
fn test() {
let text = "& is an HTML entity but &ambassador; is not.".to_string();
let res = "& is an HTML entity but &ambassador; is not.".to_string();
assert_eq!(Solution::entity_parser(text), res);
let text = "and I quote: "..."".to_string();
let res = "and I quote: \"...\"".to_string();
assert_eq!(Solution::entity_parser(text), res);
let text = "Stay home! Practice on Leetcode :)".to_string();
let res = "Stay home! Practice on Leetcode :)".to_string();
assert_eq!(Solution::entity_parser(text), res);
let text = "x > y && x < y is always false".to_string();
let res = "x > y && x < y is always false".to_string();
assert_eq!(Solution::entity_parser(text), res);
let text = "leetcode.com⁄problemset⁄all".to_string();
let res = "leetcode.com/problemset/all".to_string();
assert_eq!(Solution::entity_parser(text), res);
}