Visual Basic Code Snippet - Remove HTML Tags

Visual Basic Code Snippet - Remove HTML Tags

Visual Basic Code Snippet - Remove HTML Tags

(VB) Visual Basic code snippet to remove all HTML TAGS from a string. StripHTML strip all HTML tags from a given string and return plain text.

Bookmark:

Visual Basic Code Snippet - Remove HTML Tags

This .Net Visual Basic code snippet removes all HTML TAGS from a string. HTML stripping done by set of successful matches found by iteratively applying a regular expression pattern to the input string.

Public Function StripHTML(ByVal str As String) As String
    Return System.Text.RegularExpressions.Regex.Replace(str, "<(.|\n)*?>", String.Empty)
End Function


VB Keywords Used:

  • Regex
  • Replace

Code Snippet Information:

  • Applies To: .Net, VB, Visual Basic, CLI, HTML, Regular Expression
  • Programming Language : Visual Basic (VB)

External Resources:

Leave a comment