Groups | Blog | Home
all groups > asp.net > october 2003 >

asp.net : removeing html from a text string


Brian Henry
10/14/2003 11:20:57 PM
I want a way to remove all the html tags from a string... i have a ton of
html saved in an sql server and its indexed so i can do searches, but when i
return the text i get all the tags back (did server.encode when saveing to
the sql server) how can i remove the tags so i go from "<b>text</b>" to
"text" thanks!

Tim Stephenson
10/15/2003 10:48:43 AM
The quickest way to do this would be to use regular expressions to search
and replace the html tags in your text.
Replace(Replace(Replace(Regex.Replace(yourTextString, "<(.|\n)+?>", " "),
"<", "&lt;"), ">", "&gt;"), "'", "''")


--
Regards

Tim Stephenson MCSD.NET
Charted MCAD & MCSD.NET Early Achiever


[quoted text, click to view]

AddThis Social Bookmark Button