我需要在特定位置删除Word HTML标记。目前我正在这样做:
public string CleanWordStyle(string html)
{
StringCollection sc = new StringCollection();
sc.Add(@"
");sc.Add(@"(]+>");
sc.Add(@"(]+>");
sc.Add(@"(]+>");
sc.Add(@"(mso-bidi-|mso-fareast|mso-spacerun:|mso-list: ign|mso-ascii|mso-hansi|mso-ansi|mso-element|mso-special|mso-highlight|mso-border|mso-yfti|mso-padding|mso-background|mso-tab|mso-width|mso-height|mso-pagination|mso-theme|mso-outline)[^;]+;");
sc.Add(@"(font-size|font-family):[^;]+;");
sc.Add(@"font:[^;]+;");
sc.Add(@"line-height:[^;]+;");
sc.Add(@"class=""mso[^""]+""");
sc.Add(@"times new roman","serif";");
sc.Add(@"verdana","sans-serif";");
sc.Add(@"
sc.Add(@"
foreach (string s in sc)
{
html = Regex.Replace(html, s, "", RegexOptions.IgnoreCase);
}
html = Regex.Replace(html, @" ", @" "); //can not be read by as XmlDocument if not!
return html;
}
现在我正在使用
剥离sc.Add(@"