Home > .Net > Regular expression to remove HTML tags in VB.Net

Regular expression to remove HTML tags in VB.Net

Some time we may need to strip all the HTML tags from HTML files, like if we are doing some web scrapping. Here is simple Regular expression which will remove all the HTML Tags.

Public Sub RemoveHTMLTags(ByVal expression as string) as string
Dim pattern As String = "<(.|\n)*?>;"
Return System.Text.RegularExpressions.Regex.Replace(strHtmlString, pattern, String.Empty).Trim()
End Sub
Categories: .Net Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.