public static string StripHTML(string stringToStrip)
{
if (!string.IsNullOrEmpty(stringToStrip))
{
stringToStrip = Regex.Replace(stringToStrip, "</p(?:\s*)>(?:\s*)<p(?:\s*)>", "
", RegexOptions.IgnoreCase | RegexOptions.Compiled);
stringToStrip = Regex.Replace(stringToStrip, "<br(?:\s*)/>", "
", RegexOptions.IgnoreCase | RegexOptions.Compiled);
stringToStrip = Regex.Replace(stringToStrip, """, "''", RegexOptions.IgnoreCase | RegexOptions.Compiled);
stringToStrip = StripHtmlXmlTags(stringToStrip);
}
return stringToStrip;
}
private static string StripHtmlXmlTags(string content)
{
return Regex.Replace(content, "<[^>]+>", string.Empty, RegexOptions.IgnoreCase | RegexOptions.Compiled);
}