Java 从html字符串中删除强标记
我有一个包含html文本的s字符串。我想从中删除强标记,并将文本保留在标记内。 对于此输入:Java 从html字符串中删除强标记,java,Java,我有一个包含html文本的s字符串。我想从中删除强标记,并将文本保留在标记内。 对于此输入: some text <strong> example </strong other text 我试过了,但这是在删除强标记中的文本 String target = htmlString.replaceAll("<strong.*</strong>", ""); String target=htmlString.replaceAll(htmlString.repla
some text <strong> example </strong other text
我试过了,但这是在删除强标记中的文本
String target = htmlString.replaceAll("<strong.*</strong>", "");
String target=htmlString.replaceAll(htmlString.replace(/|/g,”);
htmlString.替换(/|/g,”);
公共类堆栈{
公共静态void main(字符串[]args){
String text=“some text示例公共类堆栈\u Ex{
公共静态void main(字符串[]args){
String text=“some text示例是java
还是javascript
?对我来说听起来更像java。此外,提供的输入有“some text示例是java
还是javascript
?对我来说更像java。此外,提供的输入有”一些文本示例
String target = htmlString.replaceAll("<strong.*</strong>", "");
htmlString.replace(/<strong>|<\/strong>/g, "");
public class Stack_Ex {
public static void main(String[] args) {
String text = "some text <strong> example </strong other text";
text = text.replaceFirst(" <strong>","");
text = text.replaceFirst(" </strong","");
System.out.println(text);
}}