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
Solved

Vb.net/Asp.net remove Html tags

Posted on 2010-09-17
3
668 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
3 Comments
 
LVL 7

Accepted Solution

by:
klakkas earned 250 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 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

829 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