Monday, July 2, 2007

Strip Tags Method

If you need to strip tags, you can you the method detailed below.

public static string StripTags(string str)
{
str = Regex.Replace(str, @"]*>", " ", RegexOptions.IgnoreCase RegexOptions.Multiline);
str = Regex.Replace(str, @"<[^<>]*[>$]?", String.Empty, RegexOptions.IgnoreCase RegexOptions.Multiline);
str = str.Replace(" ", " ");
return HttpUtility.HtmlDecode(str.ToString());
}

No comments: