2011-03-20 43 views
0

我使用正則表達式來得到一個網站上的一些信息,我有這樣的代碼:Visual Basic中的正則表達式,但沒有雙引號

Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.startkabel.nl/zoeken/index.php?zoek=" & TextBox1.Text) 

Dim response As System.Net.HttpWebResponse = request.GetResponse 

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

Dim startpagina As String = sr.ReadToEnd 

Dim sp As New System.Text.RegularExpressions.Regex("<a href=http://games.startkabel.nl>games.startkabel.nl</a></td>") 

Dim matches As MatchCollection = sp.Matches(startpagina) 


For Each itemcode As Match In matches  
    ListBox1.Items.Add(itemcode.Value.Split("""").GetValue(0))  
Next 

<a href=http://games.startkabel.nl>games.startkabel.nl</a></td>沒有""因此列表框顯示整個代碼,而我只需要這部分

games.startkabel.nl 

我已經嘗試過的代碼改成這樣:

"<a href=""http://games.startkabel.nl"">""games.startkabel.nl""</a></td>" 

但它不顯示任何結果。

有人可以幫我解決這個問題嗎?

(對不起我的英語不好)

回答

0

你們是不是要檢索的超級鏈接URL或超鏈接的名字嗎?

itemcode.Value.Split("="c, "<"c, ">"c).GetValue(2) 

將返回URL 「http://games.startkabel.nl」

itemcode.Value.Split("="c, "<"c, ">"c).GetValue(3) 

將返回超鏈接名稱 「games.startkabel.nl」

+0

非常感謝您!它的工作:D – Ruben 2011-03-20 13:01:44

相關問題