fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. string text = "One word, duel. Limes said bye.";
  10. string pattern = @"\b(?<w>\p{L}+)(?:\P{L}+(?<w>(\p{L})(?<=\1\P{L}+\1)\p{L}*))+\b";
  11. Match result = Regex.Match(text, pattern, RegexOptions.IgnoreCase);
  12. List<string> output = new List<string>();
  13. if (result.Success)
  14. {
  15. foreach (Capture c in result.Groups["w"].Captures)
  16. output.Add(c.Value);
  17. }
  18. Console.WriteLine(string.Join(", ", output));
  19. }
  20. }
  21.  
Success #stdin #stdout 0.06s 21032KB
stdin
Standard input is empty
stdout
word, duel, Limes, said