2017-02-20 90 views
0

我想要用逗號分隔的字符串放到數組中。問題是,它正在拉動表頭垃圾與所需的數據,如下圖所示:有沒有一種方法,我可以做到這一點,不會導致此問題或修改我的代碼,以便它是正確的?提前致謝!用逗號分隔的字符串到數組

Issue

我有以下代碼:

Dim values As String = EmailList.Text.Trim 
Dim list As New ArrayList  
list.AddRange(values.Split(","c)) 
ListBox.DataSource = list 
ListBox.DataBind 
+0

呵呵,文字如下:name1,name2,name3,... – Jeremy

+0

你如何做出任何改變,不會*修改代碼? – Plutonix

+0

這讀錯了,我的意思是「或一種方法來修改我的代碼,以便它是正確的。」 – Jeremy

回答

0

假設垃圾數據是一致的,總是出現你顯示的方式(用相同的表格單元格中的所有電子郵件地址),您可以

Dim intLocationOfOpenCellTag As Integer = strTest.LastIndexOf("<td>") 
    Dim intLocationOfCloseCellTag As Integer = strTest.LastIndexOf("</td>") 

    '+ 4 to account for four characters in <td> 
    Dim strCleanData = strTest.Substring((intLocationOfOpenCellTag + 4), (intLocationOfCloseCellTag - (intLocationOfOpenCellTag + 4))) 

如果每個地址是在它的流:使用基本字符串函數找到開孔標籤和閉孔標籤的位置解析它n html cell或row它會比這更復雜。

+0

這個工程!非常感謝NoAlias! – Jeremy