Stripping out all HTML tags?

Administrator

VB.NET Forum Admin
Joined
Jun 3, 2004
Messages
1,461
Programming Experience
10+
Anyone have a good way of REMOVING all HTML tags from text? I don't want to encode it, I want to REMOVE them. If I capture a column of data in a DB and it has HTML tags, how do I remove the HTML tags from the value of this column?
 

ayan

Member
Joined
Jun 9, 2004
Messages
18
Programming Experience
Beginner
i don't know if this helps mate.
VB.NET:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 	  RichTextBox1.Text = "<html>" & Constants.vbCrLf & _
 	  "<head>" & Constants.vbCrLf & _
 	  "<title>the brown monkey</title>" & Constants.vbCrLf & _
 	  "<link rel=stylesheet href=page.css>" & Constants.vbCrLf & _
 	  "</head>" & Constants.vbCrLf & _
 	  "<body>" & Constants.vbCrLf & _
 	  "the quick brown monkey jumps" & Constants.vbCrLf & _
 	  "over the lazy dog." & Constants.vbCrLf & _
 	  "</body></html>"
    End Sub
 
    Sub RemoveHTMLTags()
 	  Dim s As String = "\<(html|/html|title|/title|head|/head|body|/body|link.*)\>"
 	  RichTextBox1.Text = Regex.Replace(RichTextBox1.Text, s, "", RegexOptions.IgnoreCase)
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 	  RemoveHTMLTags()
    End Sub
if not, sorry...
 
Top Bottom