/// <summary>
/// 去除 html 标记
/// </summary>
/// <param name = "strhtml"> 包括 html 的源码 </param>
/// <zurückgegeben> 已经去除后的文字 </returns>
public static String StripHtml (String strhtml)
{
String [] aryreg = {
@"script [^>]*?>.*? </script>",
@"<(/// s*)?!
@"([/r/n]) [/s]+",
@"& (Quote |#34);",
@"& (amp |#38);",
@"& (lt |#60);",
@"& (GT |#62);",
@"& (nbsp |#160);",
@"& (IEXCL |#161);",
@"& (Cent |#162);",
@"& (Pfund |#163);",
@"& (Kopie |#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;
für (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", "");
Return Stroutput;
}