Posted By

bonitoo on 04/23/10


Tagged

html strip tag


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jwashi10
startupbrite


Strip HTML


 / Published in: VB.NET
 

Strip HTML tags from string.. Completed!

  1. Public Function StripHTML(ByVal str As String) As String
  2. Try
  3. Dim start As Integer = 0
  4. Dim [end] As Integer = 0
  5. Dim count As Integer = 0
  6.  
  7. While ((str.IndexOf("<") > -1) AndAlso (str.IndexOf(">") > -1) AndAlso (str.IndexOf("<") < str.IndexOf(">")))
  8. start = str.IndexOf("<")
  9. [end] = str.IndexOf(">")
  10. count = [end] - start + 1
  11.  
  12. str = str.Remove(start, count)
  13. End While
  14.  
  15. str = str.Replace(" ", " ")
  16. str = str.Replace(">", "")
  17. str = str.Replace(vbCr & vbLf, "")
  18.  
  19. Return str.Trim()
  20. Catch ex As Exception
  21. Throw New Exception(ex.Message)
  22. End Try
  23. End Function

Report this snippet  

You need to login to post a comment.