Thursday 4 February 2016

How to add separator to string at every N characters?

I was having a strange requirements last days and one of them is this one:

we have a string and we want to add a separator after 8 digit.

Here is the post which help me to achieve the my solution:


here is the solution that worked for me:

string x = "111111110000000011111111000000001111111100000000";
output should be :

C# : Regex.Replace(myString, ".{8}", "$0,");



No comments:

Post a Comment