fork(401) 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 delimiters = new List<string> { " ", "(", ")", ">", "<", ",", ";"};
  12. var line = "if(a>b) write(\"My new result\")";
  13. var escaped_delimiters = new List<string>();
  14. escaped_delimiters.Add(@"""[^""\\]*(?:\\.[^""\\]*)*""");
  15. escaped_delimiters.AddRange(delimiters.Select(d => Regex.Escape(d)).ToList());
  16. var pattern = "(" + String.Join("|", escaped_delimiters) + ")";
  17. var result = Regex.Split(line, pattern).Where(x => !String.IsNullOrWhiteSpace(x)).ToList();
  18. foreach (var s in result)
  19. Console.WriteLine(s);
  20. }
  21. }
Success #stdin #stdout 0.14s 24768KB
stdin
Standard input is empty
stdout
if
(
a
>
b
)
write
(
"My new result"
)