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 s = @"Start Date:
  12.  
  13. 2014-09-08
  14.  
  15.  
  16.  
  17. End Date:
  18.  
  19. 2017-09-07
  20.  
  21.  
  22.  
  23. Warranty Type:
  24.  
  25. XXX
  26.  
  27.  
  28.  
  29. Status:
  30.  
  31. Active
  32.  
  33.  
  34.  
  35. Serial Number/IMEI:
  36.  
  37. XXXXXXXXXXX
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. Description:
  48.  
  49.  
  50.  
  51. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  52. var res = Regex.Replace(s, @":\s+", ": ").Split(new[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries)
  53. .Where(p => !string.IsNullOrWhiteSpace(p))
  54. .Select(m => m.Split(new[] {": "}, StringSplitOptions.None))
  55. .ToDictionary(n => n[0], n => n[1]);
  56. if (res.ContainsKey("Start Date")) Console.WriteLine(res["Start Date"]);
  57. if (res.ContainsKey("Warranty Type")) Console.WriteLine(res["Warranty Type"]);
  58. if (res.ContainsKey("Status")) Console.WriteLine(res["Status"]);
  59. }
  60. }
Success #stdin #stdout 0.12s 24544KB
stdin
Standard input is empty
stdout
2014-09-08 
XXX 
Active