fork(1) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string[] tests = new string[]{
  9. @"*\\*",
  10. @"*\\\**",
  11. @"*\**",
  12. };
  13.  
  14. Regex re = new Regex(@"(?:[^*\\]+|\\.)+|\*");
  15.  
  16. foreach (string s in tests) {
  17. var parts = re.Matches(s)
  18. .OfType<Match>()
  19. .Select(m => m.Value)
  20. .ToList();
  21.  
  22. Console.WriteLine(string.Join(", ", parts.ToArray()));
  23. }
  24. }
  25. }
Success #stdin #stdout 0.08s 34128KB
stdin
Standard input is empty
stdout
*, \\, *
*, \\\*, *
*, \*, *