It is easiest if you never add the duplicate result:
vb Code:
'get the contents of the file Dim data As String = IO.File.ReadAllText("DNSLog.txt") 'get something to store the results in for display Dim result As New System.Text.StringBuilder 'create the pattern to match by Dim pattern As String = "[a-zA-Z0-9\.]+\.(com|net|org|info|edu|de|biz|tv|us|co|uk|eu)" 'loop through all matches and add them to the results to be displayed For Each m As System.Text.RegularExpressions.Match In System.Text.RegularExpressions.Regex.Matches(data, pattern) 'check if the result is already part of the results If Not result.ToString.Contains(String.Format("{1}{0}", Environment.NewLine, m.Value)) Then 'only add new result if it is not a duplicate result.AppendFormat("{1}{0}", Environment.NewLine, m.Value) End If Next 'display the results MsgBox(result.ToString)




Reply With Quote