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 = "xxx (aaa - bbb CC - dd - ee-FFF) (aaa2 - bbb2 CC2- dd2- ee2-FFF2)";
  12. var pattern = @"\((?<o>(?:(?! - )[^()])+)(?: - (?<o>(?:(?! - )[^()])+)){2,}\)";
  13. var ms = Regex.Matches(s, pattern);
  14. foreach (Match m in ms)
  15. {
  16. Console.WriteLine($"Matched: {m.Value}");
  17. var res = m.Groups["o"].Captures.Cast<Capture>().Select(x => x.Value);
  18. Console.WriteLine(string.Join("; ", res));
  19. }
  20. }
  21. }
Success #stdin #stdout 0.08s 134592KB
stdin
Standard input is empty
stdout
Matched: (aaa - bbb CC - dd - ee-FFF)
aaa; bbb CC; dd; ee-FFF