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.  
  14. String[] matches = Regex.Matches(input, pattern)
  15. .Cast<Match>()
  16. .Select(m => m.Value)
  17. .ToArray();
  18.  
  19. foreach (String m in matches)
  20. {
  21. Console.WriteLine(m);
  22. }
  23. }
  24. }
Success #stdin #stdout 0.06s 30540KB
stdin
Standard input is empty
stdout
add
galaxy
Milky way
elliptical
13.2B
test test