Home
Manage Your Code
Snippet: Clear Html Tags in a string (C#)
Title: Clear Html Tags in a string Language: C#
Description: Clear Html Tags in a string Views: 655
Author: Anuj Kothari Date Added: 3/16/2009
Copy Code  
1public static string StripHtml(string html, bool allowHarmlessTags)
2{
3   if (html == null || html == string.Empty)
4     return string.Empty; 
5
6   if (allowHarmlessTags)
7     return System.Text.RegularExpressions.Regex.Replace(html, "", string.Empty); 
8
9   return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", string.Empty);
10}