- this is some text
Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
ASP.NET: Strip HTML tags from a string
From Wiki
Summary: Strip HTML Tags from a string
If you have a string containing HTML and you need to strip all of the HTML out of it, one of the easiest methods is to use a Regular Expression.
Here's a simple example that shows how to use this expression:
- Imports System.Text.RegularExpressions
- Partial Class Default1
- Inherits System.Web.UI.Page
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Dim myHTML As String = "<html><head></head><body style=""color:blue;"">this is some text</body></html>"
- Response.Write(ConvertHtmlToPlainText(myHTML))
- End Sub
- Private Function ConvertHtmlToPlainText(ByVal htmlText As String) As String
- Return Regex.Replace(htmlText, "<[^>]*>", String.Empty)
- End Function
- End Class
Ouptut:
This Hack is part of the ASP.NET Hacks collection



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.