Strip all HTML tags

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
C# Code Snippets

C# Source Code Bank

See also …
edit

This C# code snippet removes all HTML tags from the specified string and returns the stripped string.

using System.Text.RegularExpressions;
...
const string HTML_TAG_PATTERN = "<.*?>";
 
static string StripHTML (string inputString)
{
   return Regex.Replace 
     (inputString, HTML_TAG_PATTERN, string.Empty);
}



Personal tools