To search and return for unique string value counts in C# through input text file?
<p>I have a log file in the following format :</p>

<pre><code>INFO [SearchServices] WX Search = Server:nomos-scanner.corp.adobe.com User:ashishg appGUID: wx Elapsed Time:875ms SaveSearchID:361
INFO [SearchServices] WX Search = Server:nomos-scanner.corp.adobe.com User:ashishg appGUID: wx Elapsed Time:875ms SaveSearchID:361
INFO [SearchServices] WX Search = Server:nomos-scanner.corp.adobe.com User: ashishg appGUID: wx Elapsed Time:875ms SaveSearchID:361
INFO [SearchServices] WX Search = Server:nomos-scanner.corp.adobe.com User:karansha appGUID: wx Elapsed Time:875ms SaveSearchID:361
INFO [SearchServices] WX Search = Server:nomos-scanner.corp.adobe.com User:gulanand appGUID: wx Elapsed Time:875ms SaveSearchID:361
INFO [SearchServices] WX Search = Server:nomos-scanner.corp.adobe.com User:ashishg appGUID: wx Elapsed Time:875ms SaveSearchID:361
</code></pre>

<p>Code that I have tried is :</p>

<pre><code>StreamReader reader = new StreamReader("test file path");     
string x = reader.ReadToEnd();

List&lt;string&gt; users = new List&lt;string&gt;();
int numberOfUsers;

Regex regex = new Regex(@"User:(?&lt;username&gt;.*?) appGUID");
MatchCollection matches = regex.Matches(x);

foreach (Match match in matches)
{
    if (!users.Contains(match.ToString())) users.Add(match.ToString());
}

Regex regex2 = new Regex(@"User: (?&lt;username&gt;.*?) appGUID");
matches = regex2.Matches(x);

foreach (Match match in matches)
{
    if (!users.Contains(match.ToString())) users.Add(match.ToString());
}

numberOfUsers = users.Count;
Console.WriteLine(numberOfUsers);
// keep screen from going away
// when run from VS.NET`
</code></pre>
