fork 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 filter = @"abc = 'def' and size = '1 x(3"" x 5"")' and (name='Sam O\'neal')";
  12. var pattern = @"('[^'\\]*(?:\\.[^'\\]*)*'|<=|>=|!=|=|>|<|\)|\(|\s+)";
  13. var tokens = Regex.Split(filter, pattern).Where(x => !string.IsNullOrWhiteSpace(x));
  14. foreach (var tok in tokens)
  15. Console.WriteLine(tok);
  16. }
  17. }
Success #stdin #stdout 0.03s 133888KB
stdin
Standard input is empty
stdout
abc
=
'def'
and
size
=
'1 x(3" x 5")'
and
(
name
=
'Sam O\'neal'
)