Example #1
0
        private static IEnumerable<string> Template(string source, Match[] matches)
        {
            if (matches.Length == 0)
                yield return source;
            else
            {
                var head = matches.First();
                var tail = matches.Skip(1).ToArray();
                var items = head.Result("$1").Split(',').Select(x => x.Trim()).ToList();
                var templates = Template(source, tail).ToList();

                foreach (var template in templates)
                    foreach (var item in items)
                        yield return template.Remove(head.Index, head.Length).Insert(head.Index, item);
            }
        }