Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 How do you remove html tags using regex ?

$
0
0
Hi I want to know how do you remove html tags using regex.
Everything what I need is how to remove html tags and leave only the text between the html tags.

The code which I have does not work as it should.
That's all I need.



Here's the code.

Code:

Try
            ListBox1.Items.Clear()
            Dim request As System.Net.HttpWebRequest = CType(System.Net.HttpWebRequest.Create("http://bestblackhatforum.com/Forum-Freebies?page=" & TextBox1.Text), Net.HttpWebRequest)
            Dim response As System.Net.HttpWebResponse = CType(request.GetResponse, Net.HttpWebResponse)

            Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

            Dim resourcecode As String = sr.ReadToEnd
            ListBox1.Text = resourcecode

            Dim r As New System.Text.RegularExpressions.Regex(String.Format("<span style="".+?"".+?</span>"))
            Dim matches As MatchCollection = r.Matches(resourcecode)

            For Each itemcode As Match In matches
                ListBox1.Items.Add(itemcode.Value.Split("""").GetValue(2))
            Next
        Catch ex As Exception

        End Try

Thanks.

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>