fork download
  1. using System;
  2. using System.Linq.Expressions;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. string pattern = @"([A-Za-z0-9.]+)|#([^#]+)#|\[([^][]+)]";
  12. string input = @"add galaxy [Milky way] elliptical 13.2B #test test #";
  13. string[] items = Regex.Split(input, pattern).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  14.  
  15. foreach (string item in items)
  16. {
  17. Console.WriteLine(item);
  18. }
  19. }
  20. }
Success #stdin #stdout 0.08s 30524KB
stdin
Standard input is empty
stdout
add
galaxy
Milky way
elliptical
13.2B
test test