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. List<string> ok = new List<string>();
  12. List<string> err = new List<string>();
  13.  
  14. var lista = new[] { "ERIK ADESIR COMPANY LA ISLA DE LA PALMA" };
  15. foreach (string dir in lista)
  16. {
  17. var match = Regex.Match(dir, @"^(.{1,32})([ ]+.{1,30})?([ ]+.{1,30})?$");
  18. if (match.Success)
  19. {
  20. var cap = match.Groups;
  21. ok.Add($"{dir};{cap[1].Value};{(cap[2].Success ? cap[2].Value.Trim() : "")};{(cap[3].Success ? cap[3].Value : "")}");
  22. }
  23. else
  24. {
  25. err.Add(dir);
  26. }
  27. }
  28. Console.WriteLine(string.Join("\n", ok));
  29. }
  30.  
  31. }
Success #stdin #stdout 0.06s 21104KB
stdin
Standard input is empty
stdout
ERIK ADESIR COMPANY LA ISLA DE LA PALMA;ERIK ADESIR COMPANY LA ISLA DE;LA PALMA;