using System; using System.Text.RegularExpressions; public class Test { public static void Main() { // your code goes here Console.WriteLine(Modify("1,2,3,4,5,6,7,8,9")); } static string Modify(string value) { string sSnr = Regex.Replace(value, "\r\n", ", "); MatchCollection matches = Regex.Matches(sSnr, Regex.Escape(",")); int anz = 0; int y; int addAnz = 0; foreach (Match m in matches) { anz++; y = anz % 3; if (y == 0) { addAnz++; sSnr = sSnr.Insert(m.Index + addAnz, Environment.NewLine); } } return sSnr; } }