fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var s = "{token1;token2;token3;...;tokenn}";
  12. var pat = @"\A{(?<val>[^;]*)(?:;(?<val>[^;]*))+}\z";
  13. var caps = new List<string>();
  14. var result = Regex.Match(s, pat);
  15. if (result.Success)
  16. {
  17. caps = result.Groups["val"].Captures.Cast<Capture>().Select(t=>t.Value).ToList();
  18. }
  19.  
  20. // DEMO
  21. Console.WriteLine(string.Join("\n", caps));
  22. }
  23. }
Success #stdin #stdout 0.03s 30248KB
stdin
Standard input is empty
stdout
token1
token2
token3
...
tokenn