try.......... Function cleanHTML(htmlStr)
Dim regEx
SET regEx = New Regexp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "<a.+?>.+?</a>"
htmlStr = regEx.Replace(htmlStr,"")
cleanHTML = htmlStr
SET regEx = Nothing
End Function
Dim regEx
SET regEx = New Regexp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "<a.+?>.+?</a>"
htmlStr = regEx.Replace(htmlStr,"")
cleanHTML = htmlStr
SET regEx = Nothing
End Function
楼上的兄弟没有考虑S里的换行
我的代码是:
...
Pattern p= Pattern.compile("(<[a-zA-Z].*?>|<[/][a-zA-Z].*?>)");//去掉所有的html标签
// Pattern p= Pattern.compile("(<[aA].*?>|<[/][aA].*?>)");//着个去掉了<a></a>,但是超级连接的文字还在啊!
Pattern p= Pattern.compile("<a.+?>.+?</a>");
Matcher m = p.matcher(string);
StringBuffer sb = new StringBuffer();
boolean result = m.find();
while (result) { m.appendReplacement(sb, "");
result = m.find();
}
m.appendTail(sb);
String TString=sb.toString();
return TString;
}
}