Search

Strip all HTML tags

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);
}