usando System.Text.RegularExpressions;//需要引用
// 利用正则表达式去掉"<"和">"之间的内容
cadena privada StripHT (cadena strHtml)
{
Regex regex=new Regex("<.+?>",RegexOptions.IgnoreCase);
cadena strOutput=regex.Replace(strHtml,"");
devolver strSalida;
}
//方法二(不知为什么此方法占用CPU100%)
cadena estática pública DropHTML(string strHtml)
{
cadena [] aryReg ={
@"<script[^>]*?>.*?</script>",
@"<(/s*)?!?((w+:)?w+)(w+(s*=?s*(([""''])( \["" ''tbnr]|[^7])*?7|w+)|.{0})|s)*?(/s *)?>",
@"([r])[s]+",
@"&(quot|#34);",
@"&(amp|#38);",
@"&(es|#60);",
@"&(gt|#62);",
@"&(nbsp|#160);",
@"&(iexcl|#161);",
@"&(centavo|#162);",
@"&(libra|#163);",
@"&(copia|#169);",
@"&#(d+);",
@"-->",
@"<!--.*"
};
cadena [] aryRep = {
"",
"",
"",
""",
"&",
"<",
">",
" ",
"xa1",//chr(161),
"xa2",//chr(162),
"xa3",//chr(163),
"xa9",//chr(169),
"",
"r",
""
};
cadena nuevoReg =aryReg[0];
cadena strOutput=strHtml;
para(int i = 0;i<aryReg.Length;i++)
{
Regex expresión regular = new Regex(aryReg[i],RegexOptions.IgnoreCase);
strOutput = regex.Replace(strOutput,aryRep[i]);
}
strOutput.Replace("<","");
strOutput.Replace(">","");
strOutput.Replace("r","");
devolver strSalida;
}
http://www.cnblogs.com/wang123/archive/2006/09/16/505758.html