我有一个matchCollection
Dim matchList As MatchCollection = Regex.Matches(...)
包含来自某个网站的所有链接。现在我想区分另一个MatchCollection或数组变量中的所有链接。因此,每个链接必须只出现一次。
有什么想法吗?
我正在使用vb.net
答案 0 :(得分:1)
您可以这样做:
' Gets all the matches.
Dim LinkMatches As MatchCollection = Regex.Matches(...)
Dim LinkList As New List(Of String)
' Gets the matches values and assign them to a list.
For Each Match As Match In LinkMatches
LinkList.Add(Match.Value)
Next
' Using the Distinct function to eliminate duplicates links.
LinkList = LinkList.Distinct.ToList