Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Vb.net/Asp.net remove Html tags

Posted on 2010-09-17
3
Medium Priority
?
673 Views
Last Modified: 2012-05-10
I need show part of text stored in a database field. But text is stored in html format. Need remove html tags to show as plain text
0
Comment
Question by:rflorencio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Accepted Solution

by:
klakkas earned 1000 total points
ID: 33700016
Use this:
'Remove all tags
    Private Function RemoveTags(ByVal inp As String) As String
        Dim res As String

        res = inp.Substring(0, inp.IndexOf("<"))
        inp = inp.Substring(inp.IndexOf("<"))

        Do While inp.IndexOf("<") >= 0
            inp = inp.Substring(inp.IndexOf(">") + 1)
            If inp.IndexOf("<") >= 0 Then
                res &= inp.Substring(0, inp.IndexOf("<"))
            Else
                res &= inp
            End If
        Loop

        res = res.Replace("&nbsp;", " ")
        res = res.Replace(vbCr, " ")
        res = res.Replace(vbLf, " ")

        Do While res.IndexOf("  ") >= 0
            res = res.Replace("  ", " ")
        Loop
        Return res

    End Function

Open in new window

0
 
LVL 10

Assisted Solution

by:WhiteMeat
WhiteMeat earned 1000 total points
ID: 33700265
regular expressions

Public Shared Function StripHtmlTags(ByVal text As String) As String
Return System.Text.RegularExpressions.Regex.Replace(text, "<(.|\n)*?>", String.Empty)
End Function

Open in new window

0
 

Author Comment

by:rflorencio
ID: 33723797
i can´t close the question, but i not know why
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question