devxlogo

March 23, 2017

Strip HTML Content from a String

To?string?HTML?tags,?use?HttpUtility???s?HTMLDecode?method?with?a?RegEx?expression.?HTMLDecode?is?available?in?System.Web?assembly. string?htmlText?=?@”Decision?Making?Techniques:?Why?should?you?be?prepared”; string?plainText?=?string.Empty; if?(!string.IsNullOrWhiteSpace(htmlText)) { ?????plainText?=?Regex.Replace(HttpUtility.HtmlDecode(htmlText),?@””,?string.Empty).Trim(); }