In my MatchCollection, I get matches of the same thing. Like this:
string text = @"match match match";
Regex R = new Regex("match");
MatchCollection M = R.Matches(text);
How does one remove duplicate matches and is it the fastest way possible?
Assume “duplicate” here means that the match contains the exact same string.
Linq
If you are using .Net 3.5 or greater such as 4.7, linq can be used to remove the duplicates of the match.
.Net 2 or No Linq
Place it into a hastable then extract the strings: