湛蓝之海 发表于 2021-10-24 15:39:41

java去掉html标签 必须首先去掉双引号的正则


public static String htmlToStr(String htmlStr){
String result = "";
boolean flag = true;
if(htmlStr==null){
return null;
}

htmlStr = htmlStr.replace("\"", ""); //去掉引号

char[] a = htmlStr.toCharArray();
int length=a.length;
for(int i=0;i<length;i++){
if(a=='<'){
flag=false;
continue;
}
if(a=='>'){
flag=true;
continue;
}
if(flag==true){
result+=a;
}
}
return result.toString();
}

https://www.uoften.com/program/jsp/20180413/47451.html
页: [1]
查看完整版本: java去掉html标签 必须首先去掉双引号的正则