public static String StripHtml(string strVar, bool convertBreaks, bool keepLinks)
{
if(FixNull(strVar) == string.Empty)
{
return (strVar);
}
else
{
Regex tags = new Regex(@"<(script|style).*?>.*?</(script|style).*?>", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
strVar = tags.Replace(strVar, "");
if(convertBreaks == true)
{
tags = new Regex(@"<br[\s]*[/]*>");
strVar = tags.Replace(strVar, "\r\n");
strVar = strVar.Replace("</p>", "\r\n\r\n");
}
if (keepLinks == true)
{
strVar = Regex.Replace(strVar, "(<)(?=/??a)", "[[[[[", RegexOptions.IgnoreCase);
}
tags = new Regex(@"<[^>]+>|</[^>]+>");
strVar = tags.Replace(strVar, "");
if (keepLinks == true)
{
strVar = strVar.Replace("[[[[[", "<");
}
strVar = strVar.Replace(" ", " ");
strVar = strVar.Replace("&edsp;", " ");
return strVar;
}
}