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

No related content found.

This entry was posted in .Net and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>