fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. string sInput = "herpdediderp (orange,(hmm)) some other crap (red,hmm)"+
  11. "buzz (blue,(hmmm) (damn) derp) (hi)";
  12. Regex re = new Regex(@"([^(]+|\([^(]*(?:\([^(]*\)[^(]*)*\))");
  13. List<string> sResult = re.Split(sInput).Where(s => !string.IsNullOrWhiteSpace(s)).ToList();
  14.  
  15. Console.WriteLine(string.Join("\n", sResult));
  16. }
  17. }
Success #stdin #stdout 0.08s 20512KB
stdin
Standard input is empty
stdout
herpdediderp 
(orange,(hmm))
 some other crap 
(red,hmm)
buzz 
(blue,(hmmm) (damn) derp)
(hi)