fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq.Expressions;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6.  
  7. class Test
  8. {
  9. private Result result;
  10. public enum Result
  11. {
  12. SUCCESS = 1,
  13. FAIL = 2,
  14. NONE = 3
  15.  
  16. }
  17.  
  18. public static void Main()
  19. {
  20. string input = @"Today at 01:05: (NAME) Failed Backup - The operation encountered an error. (NAME)
  21. Failed when backing up: A file was not found (NAME)
  22. DISK_OPEN_ERROR
  23.  
  24. Today at 01:04: (NAME) Successful Backup - Backed 42,73 MB (compressed to 7,32 MB).(Duration: 1 minute)
  25.  
  26. Today at 00:59: (NAME) Successful Backup - Backed 3,41 GB (compressed to 379,17 MB).(Duration: 4 minutes)";
  27.  
  28. Test test = new Test();
  29. var results = test.FindResult(input);
  30. foreach (var r in results)
  31. {
  32. Console.WriteLine(r);
  33. }
  34. }
  35.  
  36. public List<Result> FindResult(string text)
  37. {
  38. return Regex
  39. .Split(text, @"\r?\n\s*\r?\n")
  40. .Select(s => s.Contains("Failed") ? Result.FAIL : Result.SUCCESS)
  41. .ToList();
  42. }
  43. }
Success #stdin #stdout 0.08s 30816KB
stdin
Standard input is empty
stdout
FAIL
SUCCESS
SUCCESS