using System; using System.Text.RegularExpressions; public class Test { public static void Main() { var pattern = @"(?i)(?<=^\w(?\w)*) (\k(?<-c>)\w+ ?|(?\w+) ?)+$(?(c)(?!))"; var input = new string[] { "RPM Package Manager", "Wine is not an emulator", "GNU is not Unix", "Golf is not an acronym", "X is a valid acronym" }; var r = new Regex(pattern); foreach (var str in input) { var m = r.Match(str); Console.WriteLine(m.Success); for (int i = 0; i < m.Groups["w"].Captures.Count; ++i) Console.WriteLine(m.Groups["w"].Captures[i].Value); } } }