Home  >  Article  >  Java  >  To remove html tags in java, you must first remove the regular double quotes

To remove html tags in java, you must first remove the regular double quotes

高洛峰
高洛峰Original
2017-01-22 15:01:091037browse

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[i]==&#39;<&#39;){ 
flag=false; 
continue; 
} 
if(a[i]==&#39;>&#39;){ 
flag=true; 
continue; 
} 
if(flag==true){ 
result+=a[i]; 
} 
} 
return result.toString(); 
}

For more java to remove html tags, please pay attention to the PHP Chinese website for related articles about regular expressions that must first remove double quotes!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn