首页 > 代码库 > java 去html标签,去除字符串中的空格,回车,换行符,制表符
java 去html标签,去除字符串中的空格,回车,换行符,制表符
public static String getonerow(String allLine,String myfind)
{
Pattern pattern = Pattern.compile("<div class=\"row\">.*?</div>");
Matcher matcher = pattern.matcher(allLine);
while(matcher.find()) {
String myval = matcher.group();
int npos=myval.indexOf(myfind);
if(npos>=0)
{
npos = myval.indexOf("<span class=\"cell value\">");
if(npos>0)
{
String content = myval.substring(npos,myval.length());
content=content.replaceAll("</?[^>]+>",""); //剔出了<html>的标签
content=content.replace(" ","");
content=content.replace(".","");
content=content.replace("\"","‘");
content=content.replace("‘","‘");
content=content.replaceAll("\\s*|\t|\r|\n","");//去除字符串中的空格,回车,换行符,制表符
return content;
}
}
}
return "";
}