Source: https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions
using System; using System.Text.RegularExpressions; public class Class1 { public static void Main() { string pattern = @"\b(\w+?)\s\1\b"; string input = "This this is a nice day. What about this? This tastes good. I saw a a dog."; foreach (Match match in Regex.Matches(input, pattern, RegexOptions.IgnoreCase)) Console.WriteLine("{0} (duplicates '{1}') at position {2}", match.Value, match.Groups[1].Value, match.Index); } } // The example displays the following output: // This this (duplicates 'This') at position 0 // a a (duplicates 'a') at position 66
502900cookie-checkC# Regex Duplicate Words