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 = @":II: Own BIC / TID
  12. COBADEFFDOC BIC could not be resolved
  13. :IO: Correspondents BIC / TID
  14. abc BIC identified as:
  15. xyz AG,THE,pqe BRANCH
  16. zxc";
  17. var pattern = @"(?m)^(:[^:]+:) *(.*(?:\r?\n(?!:[^:]+:).*)*)";
  18. var dic = Regex.Matches(s, pattern)
  19. .Cast<Match>()
  20. .ToDictionary(
  21. m => m.Groups[1].Value,
  22. m => m.Groups[2].Value
  23. );
  24. foreach (var keyval in dic)
  25. Console.WriteLine("{0} >>> {1}", keyval.Key, keyval.Value);
  26. }
  27. }
Success #stdin #stdout 0.03s 134848KB
stdin
Standard input is empty
stdout
:II: >>> Own BIC / TID
COBADEFFDOC BIC could not be resolved
:IO: >>> Correspondents BIC / TID
abc BIC identified as:
xyz AG,THE,pqe BRANCH
zxc