Wednesday, April 10, 2013

Remove Html Tags from A String in ASP.net

This code snippet will strip a string of all Html tags and replace a tag with a blank space. We used the regular expression for this. Use RegularExpressions namespace
using System.Text.RegularExpressions;

  public string RemoveHTML(string in_HTML)
        {
            return Regex.Replace(in_HTML, "<(.|\n)*?>", "");
        }