我需要在特定位置去除 Word HTML 标签。目前我正在这样做:
public string CleanWordStyle(string html)
{
StringCollection sc = new StringCollection();
sc.Add(@"<table\b[^>]*>(.*?)</table>");
sc.Add(@"(<o:|</o:)[^>]+>");
sc.Add(@"(<v:|</v:)[^>]+>");
sc.Add(@"(<st1:|</st1:)[^>]+>");
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(@"<p> </p>");
sc.Add(@"<p> </p>");
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;
}
现在我正在剥离带有 的<p>
标签的整个 HTML sc.Add(@"<p> </p>");
,但我想要的是:如果我点击表格标签,它应该停止替换,直到它点击表格结束标签。可能吗?