using System.Collections.Generic;
using System.Text.RegularExpressions;
private static string[] Tokenize(string expression)
List<string> result = new List<string>();
List<string> tokens = new List<string>();
tokens.Add("(^([\\d.\\d]+))");
tokens.Add("(^[&|<=>!]+)");
tokens.Add("(?!\\+)(?:\"((?:\\\\\"|[^\"])*)\"?)");
while (0 != expression.Length)
foreach (string token in tokens)
Match match = Regex.Match(expression, token);
if (false == match.Success)
result.Add(match.Groups[1].Value);
expression = Regex.Replace(expression, token, "");
expression = Regex.Replace(expression, @"\s*\+\s*", "");
public static void Main()
string[] res = Tokenize("H5 + \" is smaller than (\\\") \" + 10");
foreach( string s in res )
Console.WriteLine(">" + s + "<");