using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var delimiters = new List { " ", "(", ")", ">", "<", ",", ";"}; var line = "if(a>b) write(\"My new result\")"; var escaped_delimiters = new List(); escaped_delimiters.Add(@"""[^""\\]*(?:\\.[^""\\]*)*"""); escaped_delimiters.AddRange(delimiters.Select(d => Regex.Escape(d)).ToList()); var pattern = "(" + String.Join("|", escaped_delimiters) + ")"; var result = Regex.Split(line, pattern).Where(x => !String.IsNullOrWhiteSpace(x)).ToList(); foreach (var s in result) Console.WriteLine(s); } }