using System.Text.RegularExpressions;
public static void Main(){
Regex regex = new Regex(@"\b(?<word>\w+)\s+(\k<word>)\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
string text = "The quick brown fox fox jumps over the lazy dog dog";
MatchCollection matches = regex.Matches(text);
Console.WriteLine("Match count " + matches.Count);
foreach(Match match in matches){
GroupCollection groups = match.Groups;
Console.WriteLine("Match word " + groups["word"].Value);
foreach(Group group_ in groups)
Console.WriteLine("Position " + group_.Index);