Add matches to the list if they have not been added yet? Or just keep a list of what has already been added? Sort of:
List<string> seen = new List<string>();
string line = string.Empty;
while ((line = file.ReadLine()) != null)
{
foreach (Match match in Regex.Matches(line, @"(\w*)\.\."))
{
if (!seen.Contains(line))
{
Console.WriteLine(line);
seen.Add(line);
}
}
}
edit: I realized that you were here; if you really need the value of the match group, replace the line in the conditional block with match.Groups [1] .Value ...
source
share