<summary>///Remove HTML tags///</summary>//<param name = "Nohtml" > includes HTML source code </param>//<returns> removed text </returns> public static St Ring nohtml (String htmlstring) {//delete script htmlstring = Regex.Replace (htmlstring, @ "<scrip T[^>]*?>.*?</script> "," ", regexoptions.ignorecase); Delete html htmlstring = Regex.Replace (htmlstring, @ "< (. [ ^>]*) > "," ", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "([\ r \ n]) [\s]+", "", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "-and", "", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "<!--. *", "", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "& (quot| #34);", "\" ", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "&(amp| #38); "," & ", Regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "& (lt| #60);", "<", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "& (gt| #62);", ">", Regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "& (nbsp| #160);", "", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "& (iexcl| #161);", "\xa1", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "& (cent| #162);", "\xa2", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "& (pound| #163);", "\xa3", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "& (copy| #169);", "\xa9", regexoptions.ignorecase); htmlstring = Regex.Replace (htmlstring, @ "(\d+);", "", regexoptions.ignorecase); Htmlstring.replace ("<", ""); Htmlstring.replace (">", ""); Htmlstring.replace ("\ r \ n "," "); htmlstring = HttpContext.Current.Server.HtmlEncode (htmlstring). Trim (); return htmlstring; }
Remove HTML tags