none
Listview and Regex extraction RRS feed

  • Question

  • Hello Programmers, please i want you to help me with converting this html into regex.. i have been trying for like a week now and still haven't got it right. please help me out. The solution i made is found below.

    HTML

    <a class="BBclass" data-sessionlink="tttttt" title="one big title" rel="bbb" href="https://www.mysite.com">

        <span class="title" dir="ltr">zero big</span>
        <span id="description-id-514677" class="msd">one big</span>
        <span class="nvb">two big</span>
        <span class="bcv">third big</span>

    </a>

    MY CODE

        Dim span_match As New Regex("<a[^<>]*class=""BBclass""[^<>].*?href=""(?<liNK>[^""].*?)""[^<>]*>\s" & _
                                    "<span[^<>]*class=""title""[^>].*?>(?<titLE>.*?)</span>\s" & _
                                    "<span\s+id=""description-id-([0-9])""\s+class=""msd""[^<>]*>(?<descrip>.*?)</span>\s" & _
                                    "<span[^<>]*class=""nvb""[^<>]*>(?<upLOADer>.*?)</span>\s" & _
                                    "<span[^<>]*class=""bcv""[^<>]*>(?<viEWER>.*?)</span>\s" & _
                                    "</a>")

      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
             Dim matches As MatchCollection = span_match.Matches(Me.TextBox1.Text, RegexOptions.Multiline)
            For Each m As Match In matches
                Dim lvi As New ListViewItem
                lvi.Text = (m.Groups("titLE").Value)
                'lvi.SubItems.Add(View_numbr & vbCrLf)
                ' lvi.SubItems.Add( & vbCrLf)
                lvi.SubItems.Add(m.Groups("liNK").Value & vbCrLf)
                lvi.SubItems.Add(m.Groups("descrip").Value & vbCrLf)
                lvi.SubItems.Add(m.Groups("upLOADer").Value & vbCrLf)
                lvi.SubItems.Add(m.Groups("viEWER").Value & vbCrLf)
                ListView1.Items.Add(lvi)
            Next 

    End Sub

    But it is not working... please, help me to write the regex so as to make it work please.

    Thanks for your understanding Great programmers.

    Thursday, March 5, 2015 2:49 PM

Answers

All replies