fork(3) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var pattern = @"(?i)(?<=^\w(?<c>\w)*) (\k<c>(?<-c>)\w+ ?|(?<w>\w+) ?)+$(?(c)(?!))";
  9. var input = new string[] {
  10. "RPM Package Manager",
  11. "Wine is not an emulator",
  12. "GNU is not Unix",
  13. "Golf is not an acronym",
  14. "X is a valid acronym"
  15. };
  16.  
  17. var r = new Regex(pattern);
  18. foreach (var str in input)
  19. {
  20. var m = r.Match(str);
  21. Console.WriteLine(m.Success);
  22. for (int i = 0; i < m.Groups["w"].Captures.Count; ++i)
  23. Console.WriteLine(m.Groups["w"].Captures[i].Value);
  24. }
  25. }
  26. }
Success #stdin #stdout 0.09s 34536KB
stdin
Standard input is empty
stdout
True
True
an
True
is
False
True
is
a
valid
acronym