background image
html = ReplaceHtml(html, "<", ref count);
html = ReplaceHtml(html, ">", ref count);
html = ReplaceHtml(html, " ", ref count);
html = ReplaceHtml(html, "&", ref count);
html = html.Replace("<br>", "<br />");
//用正则去掉不要的 html 标签
//因为考虑到可能有自定义的一些标签,暂时没想到好的方法去做,所以暂时没
StringBuilder sbResult = new StringBuilder();
int temp = 0;//计数器
while (true)
{
if (html[temp].ToString() == "<")
{
while (true)
{
if (html[temp].ToString() == ">")
{
count++;
break;
}
sbResult.Append(html[temp]);
temp++;
}
}
if (count == 0)
{
break;
}
sbResult.Append(html[temp]);
temp++;
count--;
}
//这里写的有些麻烦,还希望大家帮忙改正
html = sbResult.ToString().Replace("< />", " ").Replace("<&/>",
"&").Replace("<</>", "<").Replace("<>/>", ">");