我試圖解析網絡文件中的一些字符串,並將解析的內容組織到列表視圖中。那麼它不像我想的那麼容易哈哈。解析foreach語句中的數據,然後添加到列表視圖
這是我試圖解析
array(7) { [0]=> string(1) "0" [1]=> string(5) "hefqn" [2]=> string(23) "SP-Branding SP-Digital " [3]=> string(18) "all hail the hefqn" [4]=> string(11) "rune-server" [5]=> string(6) "tickle" [6]=> string(23) "http://www.prntscr.com" }
array(7) { [0]=> string(1) "1" [1]=> string(6) "hefqn2" [2]=> string(23) "SP-Branding SP-Digital " [3]=> string(18) "2ll hail the hefqn" [4]=> string(11) "rune-server" [5]=> string(6) "tickle" [6]=> string(23) "http://www.prntscr.com" }
這是在一個數據庫中的兩個條目的字符串,第一個是第一項,第二個是第二項。
現在,我試圖擺脫上面的代碼中的文本是這樣的(我會把*之前和之後文本我試圖解析)
array(7) { [0]=> string(1) "***0***" [1]=> string(5) "***hefqn***" [2]=> string(23) "***Digital***" [3]=> string(18) "***test***" [4]=> string(11) "***rune-server***" [5]=> string(6) "***tickle***" [6]=> string(23) "***http://www.prntscr.com***" }
array(7) { [0]=> string(1) "***1***" [1]=> string(6) "***hefqn2***" [2]=> string(23) "***Branding***" [3]=> string(18) "***test2***" [4]=> string(11) "***rune-server***" [5]=> string(6) "***tickle***" [6]=> string(23) "***http://www.prntscr.com***" }
趁現在解析文本,它在foreach語句中,因爲我抓取了多個數據庫條目,它們都具有該佈局。
列表視圖看起來像這樣 http://i.stack.imgur.com/rqCXA.png
我一直在努力,現在摸不着頭腦了一個小時,我似乎無法得到它的權利。
有沒有人有任何想法,他們如何做到這一點?非常感謝!!
PS下面是我嘗試過,把它添加到每個子項而不是一次的每一行
Dim test As New WebClient
Dim s As String = test.DownloadString(TheStringIPosted)
For Each myMatch1 As Match In New Regex("""(.*?)""", RegexOptions.None).Matches(s)
Dim lvi As ListViewItem
lvi = ListView1.Items.Add(myMatch1.Groups.Item(1).ToString)
lvi.SubItems.Add(myMatch1.Groups.Item(1).ToString)
lvi.SubItems.Add(myMatch1.Groups.Item(1).ToString)
lvi.SubItems.Add(myMatch1.Groups.Item(1).ToString)
lvi.SubItems.Add(myMatch1.Groups.Item(1).ToString)
lvi.SubItems.Add(myMatch1.Groups.Item(1).ToString)
lvi.SubItems.Add(myMatch1.Groups.Item(1).ToString)
Next