/// <résumé>
/// 去除 html 标记
/// </summary>
/// <param name = "strhtml"> 包括 html 的源码 </ param>
/// <retourne> 已经去除后的文字 </peeturns>
String statique publique striphtml (String strhtml)
{
String [] aryreg = {
@ "<script [^>] *?>. *? </ script>",
@ "<(/// s *)?!? ((/ w +:)? / w +) (/ w + (/ s * =? / s * (([" "']) (fichier: // [" "' tbnr] | [^ / 7]) *? / 7 | / w +) |. {0}) | / s) *? (/// S *)?>",,,,,, 0}) | /
@ "([/ r / n]) [/ s] +",
@ "& (quot | # 34);",
@ "& (amp | # 38);",
@ "& (lt | # 60);",
@ "& (gt | # 62);",
@ "& (nbsp | # 160);",
@ "& (iExcl | # 161);",
@ "& (cent | # 162);",
@ "& (livre | # 163);",
@ "& (copie | # 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;
pour (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;
}