fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string input = "12 / 34+(45-56)*678";
  9. string pattern = "(?=[( ,)*/+-])|(?<=[( ,)*/+-])";
  10.  
  11. string[] substrings = Regex.Split(input, pattern);
  12. foreach (string match in substrings)
  13. {
  14. Console.WriteLine("'{0}'", match);
  15. }
  16. }
  17. }
Success #stdin #stdout 0.08s 24496KB
stdin
Standard input is empty
stdout
'12'
' '
'/'
' '
'34'
'+'
'('
'45'
'-'
'56'
')'
'*'
'678'