See how easily you can remove all formatting (HTML) from a text – just call this method:
C#
public static string StripTagsRegex(string source)
{
return Regex.Replace(source, "<.*/?>", string.Empty);
}And how does it work? < and > are the boundary characters. . means any character, including digits, and * means that this character must occur at least 0 times. These 2 regex commands are best always used together – especially with other metacharacters and other character groups. The quantifier ? at the end means at least 0 times and at most once. So if any HTML tag at the end of the string is left unclosed, it will be removed too.