HTML实体解码java

HTML实体解码java,java,php,regex,Java,Php,Regex,什么是html_entity_decode$string的Java等价物,ENT_引号是“UTF-8”; 在PHP中。 例如: 这是我的文本 Mivan is an aluminium formwork system developed by a European construction company. In 1990, the Mivan Company Ltd. from Malaysia started manufacturing these formwork systems. Tod

什么是html_entity_decode$string的Java等价物,ENT_引号是“UTF-8”; 在PHP中。 例如:

这是我的文本

Mivan is an aluminium formwork system developed by a European construction company. In 1990, the Mivan Company Ltd. from Malaysia started manufacturing these formwork systems. Today, more than 30,000sqm of formwork from Mivan Co. Ltd. 

Advantages:

· More seismic resistance

· Increased durability

· Lesser number of joints and reduced leakages

· Higher carpet area
所需格式为:

Mivan is an aluminium formwork system developed by a European construction company. In 1990, the Mivan Company Ltd. from Malaysia started manufacturing these formwork systems. Today, more than 30,000sqm of formwork from Mivan Co. Ltd. Advantages: · More seismic resistance · Increased durability · Lesser number of joints and reduced leakages .Higher carpet area.
在java中使用以下正则表达式删除空格/制表符/新行是行不通的

comment=comment.replaceAll("\\s+", "");
comment=comment.replaceAll("\t\n\r", "");

只需将一个或多个换行符替换为单个空格即可

String s ="Mivan is an aluminium formwork system developed by a European construction company. In 1990, the Mivan Company Ltd. from Malaysia started manufacturing these formwork systems. Today, more than 30,000sqm of formwork from Mivan Co. Ltd. \n" + 
            "\n" + 
            "Advantages:\n" + 
            "\n" + 
            "· More seismic resistance\n" + 
            "\n" + 
            "· Increased durability\n" + 
            "\n" + 
            "· Lesser number of joints and reduced leakages\n" + 
            "\n" + 
            "· Higher carpet area";
String comment = s.replaceAll("[\\n\\r]+", " ");
System.out.println(comment);
输出:


您只需将所有空白替换为一个空格:

comment = comment.replaceAll("\\s+", " ");

这与HTML实体有什么关系?代码是否包含任何html实体?这不是您在示例中给出的文本。你能编辑你的问题并写出你有困难的实际文本、你真正期望的结果、你正在使用的代码以及该代码产生的你不喜欢的结果吗?顺便问一下,相关的PHP命令不是strip_标记,而是html_实体_解码吗?
comment = comment.replaceAll("\\s+", " ");