RegularExpression remove html tags

RegularExpression remove html tags
Remove all html tags from html contents using regular expression. Here are C#.net and VB.net example to remove all html tags from given content.
Asp.net C# remove all html tags from given html contents.
public string ParserHtml(string html)
{
return System.Text.RegularExpressions.Regex.Replace(html, @"<[^>]*>", "").Trim();
}
VB.net function to remove all HTML tags from html content.
Public Function ParserHtml(html As String) As String
Return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", "").Trim()
End Function

How to use above functions? You just need to pass the html content to the above function and get the plain text output.

To learn REgular expressions, I recommand you to follow below links and install the software.


You may want to remove html tags from response recived by HttpWebResponse object, there you can use above expression.

You can learn regualr expression using below tool

http://www.ultrapico.com/

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5