fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. var strBackups = @"wbadmin 1.0 - Backup command-line tool
  8. (C) Copyright 2013 Microsoft Corporation. All rights reserved.
  9.  
  10. Backup time: 01.09.2015 11:51
  11. Backup target: 1394/USB Disk labeled BIGGER2(F:)
  12. Version identifier: 09/01/2015-06:51
  13. Can recover: Volume(s), File(s), Application(s), Bare Metal Recovery, System State
  14. Snapshot ID: {060e3b44-7b80-49bf-97c4-3f3b9908dec6}
  15.  
  16. Backup time: 06.09.2015 10:36
  17. Backup target: 1394/USB Disk labeled BIGGER2(F:)
  18. Version identifier: 09/06/2015-05:36
  19. Can recover: Volume(s), File(s), Application(s), Bare Metal Recovery, System State
  20. Snapshot ID: {64af3693-362d-42dc-ae5f-566b3f2d40be}
  21.  
  22. Backup time: 06.09.2015 11:00
  23. Backup target: 1394/USB Disk labeled BIGGER2(F:)
  24. Version identifier: 09/06/2015-06:00
  25. Can recover: Volume(s), File(s), Application(s), Bare Metal Recovery, System State
  26. Snapshot ID: {d9d50a01-6907-40a1-9c57-1f45de76b9ec}
  27.  
  28. ";
  29.  
  30. var regBackups = new System.Text.RegularExpressions.Regex("(?:.+\r?\n){2}\r?\n((?:.+\r?\n){5})+",
  31. System.Text.RegularExpressions.RegexOptions.Compiled
  32. );
  33.  
  34. var match = regBackups.Match(strBackups);
  35. if (!match.Success)
  36. Console.WriteLine("<not matched>");
  37. while (match.Success)
  38. {
  39. for (var i = 1; i < match.Groups.Count; i++)
  40. {
  41. foreach (var c in match.Groups[i].Captures)
  42. {
  43. Console.WriteLine("=============================");
  44. Console.WriteLine(c);
  45. Console.WriteLine("=============================");
  46. }
  47. }
  48. match = match.NextMatch();
  49. }
  50.  
  51. }
  52. }
Success #stdin #stdout 0.11s 24512KB
stdin
Standard input is empty
stdout
=============================
Backup time: 01.09.2015 11:51 
Backup target: 1394/USB Disk labeled BIGGER2(F:)
Version identifier: 09/01/2015-06:51
Can recover: Volume(s), File(s), Application(s), Bare Metal Recovery, System State
Snapshot ID: {060e3b44-7b80-49bf-97c4-3f3b9908dec6}

=============================
=============================
Backup time: 06.09.2015 11:00 
Backup target: 1394/USB Disk labeled BIGGER2(F:)
Version identifier: 09/06/2015-06:00
Can recover: Volume(s), File(s), Application(s), Bare Metal Recovery, System State
Snapshot ID: {d9d50a01-6907-40a1-9c57-1f45de76b9ec}

=============================