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 strs = new List<string> {"VA001748714600006640126132202KING PEPERM E STRONG 4P 4X44G000099","VA 00174 871460000664 012 6132202 KING PEPERM E STRONG 4P 4X44G 000099"};
  12. var rx = new Regex(@"^(\w{2})\s*(\w{5})\s*(\w{12})\s*(\d{3})\s*(\d{7})\s*(.*?)\s*(\d{6})$", RegexOptions.Compiled);
  13. object[] obj = null;
  14. foreach (var s in strs)
  15. {
  16. var m = rx.Match(s);
  17. if (m.Success)
  18. {
  19. obj = new object[] {
  20. m.Groups[1].Value,
  21. m.Groups[2].Value,
  22. m.Groups[3].Value,
  23. int.Parse(m.Groups[4].Value).ToString(),
  24. m.Groups[5].Value,
  25. m.Groups[6].Value,
  26. m.Groups[7].Value
  27. };
  28. Console.WriteLine(string.Join(", ", obj));
  29. }
  30. // return obj;
  31. }
  32. }
  33. }
Success #stdin #stdout 0.06s 134592KB
stdin
Standard input is empty
stdout
VA, 00174, 871460000664, 12, 6132202, KING PEPERM E STRONG 4P 4X44G, 000099
VA, 00174, 871460000664, 12, 6132202, KING PEPERM E STRONG 4P 4X44G, 000099