using System.Text.RegularExpressions;
public static class HtmlRemoval
public static string StripTagsRegex(string source)
return Regex.Replace(source, "<.*?>", string.Empty);
static Regex _htmlRegex = new Regex("<.*?>", RegexOptions.Compiled);
public static string StripTagsRegexCompiled(string source)
return _htmlRegex.Replace(source, string.Empty);
public static string StripTagsCharArray(string source)
char[] array = new char[source.Length];
for (int i = 0; i < source.Length; i++)
return new string(array, 0, arrayIndex);
public static void Main()
string ss = "<b><i>The tag is about to be removed</i></b>";
string result = HtmlRemoval.StripTagsCharArray(ss);
Console.WriteLine(result);