Remove HTML tags using Regular Expression in C#

Raja
Posted by Raja under C# category on | Points: 40 | Views : 351
Here is a C# function that can be used to remove HTML tags from the content. It will ensure that returned content is pure text.

public static string RemoveHtml(string source)
{
return Regex.Replace(source, "<.*?>|&.*?;", string.Empty);
}


This also removes &nbsp; (blank space) from the content.

Thanks

Comments or Responses

Login to post response