public string ClearHtml(string HtmlStr) { string tmpStr = HtmlStr; tmpStr = ReplaceHtml("&#[^>]*;", tmpStr, ""); tmpStr = ReplaceHtml("</?marquee[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?object[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?param[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?embed[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?table[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml(" ", tmpStr, ""); tmpStr = ReplaceHtml("</?tr[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?th[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?p[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?a[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?img[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?tbody[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?li[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?span[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?div[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?th[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?td[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?script[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("(javascript|jscript|vbscript|vbs):", tmpStr, ""); tmpStr = ReplaceHtml("on(mouse|exit|error|click|key)", tmpStr, ""); tmpStr = ReplaceHtml("<//?xml[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("<///?[a-z]+:[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?font[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?b[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?u[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?i[^>]*>", tmpStr, ""); tmpStr = ReplaceHtml("</?strong[^>]*>", tmpStr, ""); return tmpStr; } public string ReplaceHtml(string Pattern, string HtmlStr, string replacement) { System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex(Pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase); if(rx.IsMatch(HtmlStr)) return rx.Replace(HtmlStr, replacement); return HtmlStr; }