OffSight Web Design and Consultancy - 01543 426 142
Home : Tutorials

Strip All Html From A String


Added by David Coleman on 29 May 2010

Sometimes, such as when you want to show a brief snippet of text in search results, you'll want to strip all of the HTML tags out of a string so that you don't end up with un-finished tags.

This can be simply accomplished with the following line of code (in VB):

yourString = Regex.Replace(yourString,"\<.*?\>", String.Empty)

This code uses a regular expression to find all text in the string between triangle brackets <> and then replaces it with an empty string.

Simples!



Share this page  
What Do Our
Customers Think?
open quotes Chase Tiling Academy has recently had a web site ‘make-over’. OffSight gave us all the help and advice that was needed. The company has provided us with an excellent service, and is always ‘on hand’ when help is required. close quotes

Margaret Cockayne, Chase Tiling

open quotes