fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using System.IO;
  6. using System.Text;
  7.  
  8. public class Test
  9. {
  10. public static void Main()
  11. {
  12. string pattern = @"\b(?<name>[A-Za-z0-9]+)\s*=\s*(?:\""(?<people>[A-Za-z0-9]+)\"",?\s*)+;";
  13. string input = @"People = ""Alice"", ""Bob"", ""Charlie"", ""David"", ""Erica"", ""Fred"";";
  14. Match match = Regex.Match(input, pattern);
  15. var name = match.Groups["name"].Value;
  16. var strings = match.Groups["people"].Captures.Select(c => c.Value);
  17.  
  18. Console.WriteLine(name);
  19.  
  20. foreach (String s in strings)
  21. {
  22. Console.WriteLine("--> "+ s);
  23. }
  24. }
  25. }
Success #stdin #stdout 0.09s 30172KB
stdin
Standard input is empty
stdout
People
--> Alice
--> Bob
--> Charlie
--> David
--> Erica
--> Fred