Remove HTML entities from text
17/10/2019 12:33
Sometimes we get text from user with html formatting (e. g. when text was copy pasted). Following method shoud remove this formatting
using System;
using System.Text.RegularExpressions;
using System.Web;
public static string CleanFromHtml(string input)
{
var tagsRemoved = Regex.Replace(input, "<.*?>", String.Empty);
string normalString = HttpUtility.HtmlDecode(tagsRemoved);
return normalString;
}
public static string CleanFromHtml(string input)
{
var tagsRemoved = Regex.Replace(input, "<.*?>", String.Empty);
string normalString = HttpUtility.HtmlDecode(tagsRemoved);
return normalString;
}