/// <summary>
/// 去除 html 标记
/// </summary>
/// <param name = "strhtml"> 包括 html 的源码 </param>
/// <mirante> 已经去除后的文字 </devuelto>
Cadena pública estática Striphtml (cadena STHTML)
{
cadena [] aryreg = {
@"<script [^>]*?>.*? </script>",
@"<(/// s*)?
@"([/r/n]) [/s]+",
@"& (quot |#34);",
@"& (amp |#38);",
@"& (LT |#60);",
@"& (GT |#62);",
@"& (NBSP |#160);",
@"& (IEXCL |#161);",
@"& (Cent |#162);",
@"& (libra |#163);",
@"& (copia |#169);",
@"&#(/d+);",
@"->",
@"<!-.*/n"
};
String [] aryrep = {
"",
"",
"",
"/" ",
"&",
"<",
">",
"",
"/xa1", // chr (161),
"/xa2", // chr (162),
"/xa3", // chr (163),
"/xa9", // chr (169),
"",
"/r/n",
"
};
String newreg = aryreg [0];
string stroutput = strhtml;
para (int i = 0; i <aryreg.length; i ++)
{
regex regex = new Regex (aryreg [i], regexOptions.ignorecase);
stroutput = regex.replace (stroutput, aryrep [i]);
}
stroutput.replace ("<", "");
stroutput.replace (">", "");
stroutput.replace ("/r/n", "");
devolver stroutput;
}