fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static string SplitToLines(string str, int n)
  7. {
  8. return Regex.Replace(str, ".{"+n+"}(?!$)", "$0\n");
  9. }
  10.  
  11. public static void Main()
  12. {
  13. Console.WriteLine("{0}", SplitToLines("0123456789qwertyuiop[]asdfghjkl;'zxcvbnm", 10));
  14. Console.WriteLine("==========");
  15. Console.WriteLine("{0}", SplitToLines("0123456789qwertyuiop[]asdfghjkl;'zxcvbnmzxc", 10));
  16. Console.WriteLine("==========");
  17. Console.WriteLine("{0}", SplitToLines("0123456789", 10));
  18. Console.WriteLine("==========");
  19. Console.WriteLine("{0}", SplitToLines("01234567", 10));
  20. Console.WriteLine("==========");
  21. }
  22. }
Success #stdin #stdout 0.03s 134848KB
stdin
Standard input is empty
stdout
0123456789
qwertyuiop
[]asdfghjk
l;'zxcvbnm
==========
0123456789
qwertyuiop
[]asdfghjk
l;'zxcvbnm
zxc
==========
0123456789
==========
01234567
==========