fork download
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. public class Issue
  7. {
  8. public int Id { get; set; }
  9. public string IssueName { get; set; }
  10. public string Summary { get; set; }
  11. public string Solution { get; set; }
  12. public string InternalNodes { get; set; }
  13. public string ExternalNodes { get; set; }
  14. }
  15.  
  16. public class Test
  17. {
  18. public static string GetText()
  19. {
  20. using (var sr = new StreamReader(Console.OpenStandardInput(), Console.InputEncoding))
  21. return sr.ReadToEnd();
  22. }
  23.  
  24. public static void Main()
  25. {
  26. var issues = Regex.Matches(GetText(), @"Issue\s*(\d+):\s*([^\r\n]*?)\s*\r?\n(?:Summary:\s*([^\r\n]*?)\s*\r?\n|Solution:\s*([^\r\n]*?)\s*\r?\n|Affected Nodes: Internal\s*([^\r\n]*?)\s*\r?\n|Affected Nodes: External\s*([^\r\n]*?)\s*\r?\n)*")
  27. .Cast<Match>()
  28. .Select(m => new Issue
  29. {
  30. Id = int.Parse(m.Groups[1].Value),
  31. IssueName = m.Groups[2].Value,
  32. Summary = m.Groups[3].Value,
  33. Solution = m.Groups[4].Value,
  34. InternalNodes = m.Groups[5].Value,
  35. ExternalNodes = m.Groups[6].Value,
  36. })
  37. .ToList();
  38.  
  39. foreach (var x in issues)
  40. Console.WriteLine("{0} {1} {2,-6} {3,-6} {4,-12} {5,-12}", x.Id, x.IssueName, x.Summary, x.Solution, x.InternalNodes, x.ExternalNodes);
  41. }
  42. }
Success #stdin #stdout 0.09s 31136KB
stdin
Issue 1: test
Summary: test
Solution: первая
Affected Nodes: Internal 11.100.3.333 
Affected Nodes: External 33.33.333.333 (test)

Issue 2: test
Summary: test
Solution: test
Affected Nodes: Internal 11.100.3.333 

Issue 3: test
Summary: вторая
Solution: test
Affected Nodes: External 33.33.333.333 (test)

Issue 4: test
Summary: test
Solution: test
Affected Nodes: Internal 22.211.4.444 
Affected Nodes: External 33.33.333.333 (test)

Issue 5: test
Summary: test
Solution: test
Affected Nodes: Internal 11.100.3.333
stdout
1   test   test     первая   11.100.3.333   33.33.333.333 (test)
2   test   test     test     11.100.3.333               
3   test   вторая   test                    33.33.333.333 (test)
4   test   test     test     22.211.4.444   33.33.333.333 (test)
5   test   test     test