Blueprint

Removing All HTML Tags from a String

1   home 2   archive 3   old site 4   twitter 5   contact me

Removing All HTML Tags from a String

Remove all HTML tags from your code

I have just noticed that I had a problem with this site in that the short preview shown on the homepage contain parts of HTML that was within the main body of the post, and this caused some of the site to break.

Once I had spotted the oversite I decided to fix it with a simple Regular Expression.

Here is the code in VB.NET

Dim strRegEx As String = "<[^>]*>"

Dim myRegex As New Regex(strRegEx)

strStringToRemoveHTMLFrom = myRegEx.Replace(strStringToRemoveHTMLFrom, " ")

Three lines of code and the problem has disappeared.

Add Comments



Add Comment