fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. // your code goes here
  9. Console.WriteLine(Modify("1,2,3,4,5,6,7,8,9"));
  10. }
  11.  
  12. static string Modify(string value)
  13. {
  14. string sSnr = Regex.Replace(value, "\r\n", ", ");
  15.  
  16. MatchCollection matches = Regex.Matches(sSnr, Regex.Escape(","));
  17. int anz = 0;
  18. int y;
  19. int addAnz = 0;
  20. foreach (Match m in matches)
  21. {
  22. anz++;
  23. y = anz % 3;
  24. if (y == 0)
  25. {
  26. addAnz++;
  27. sSnr = sSnr.Insert(m.Index + addAnz, Environment.NewLine);
  28. }
  29. }
  30.  
  31. return sSnr;
  32. }
  33. }
Success #stdin #stdout 0.07s 19612KB
stdin
Standard input is empty
stdout
1,2,3,
4,5,6,
7,8,9