fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Collections.Specialized;
  4. class Program
  5. {
  6. static void Main() {
  7. string s1 = @"[Wsg-Fs]-A-A-A-Cgbs-Sg7-[Wwg+s-Fs]-A-A-Afk-Cgbs-Sg7";
  8. var myRegex = new Regex(@"\[[^\]]*\]|(-)");
  9. var group1Caps = new StringCollection();
  10.  
  11. string replaced = myRegex.Replace(s1, delegate(Match m) {
  12. if (m.Groups[1].Value == "") return m.Groups[0].Value;
  13. else return "SPLIT_HERE";
  14. });
  15.  
  16. string[] splits = Regex.Split(replaced,"SPLIT_HERE");
  17. foreach (string split in splits) Console.WriteLine(split);
  18.  
  19. Console.WriteLine("\nPress Any Key to Exit.");
  20. Console.ReadKey();
  21.  
  22. } // END Main
  23. } // END Program
  24.  
Success #stdin #stdout 0.08s 34040KB
stdin
Standard input is empty
stdout
[Wsg-Fs]
A
A
A
Cgbs
Sg7
[Wwg+s-Fs]
A
A
Afk
Cgbs
Sg7

Press Any Key to Exit.