Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 52 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. string str ="abcdefg1234567qwertyuzxcvbnm";
  2.    
  3. Console.WriteLine(str);
  4.    
  5. void Main()
  6. {
  7.     string str ="abcdefg1234567qwertyuzxcvbnm";
  8.     string result = SplitStr(str, 7);
  9.     //result.Dump();
  10. }
  11.  
  12. // Define other methods and classes here
  13.  
  14. public string SplitStr(string str, int maxSymbols)
  15. {
  16.     var sb = new StringBuilder();
  17.     var counter = 0;
  18.     foreach (var element in str)
  19.     {
  20.         if (counter == maxSymbols)
  21.         {
  22.             sb.Append(" ");
  23.             counter = 0;
  24.         }
  25.  
  26.         sb.Append(element);
  27.         counter++;
  28.     }
  29.     return sb.ToString();
  30. }
  31.    
  32. string str = "abcdefg1234567qwertyuzxcvbnm";
  33. string res = Regex.Replace(str, ".{7}", "$0 ");
  34. Console.WriteLine(res);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top