format 4549163506238472 to 4549-1635-0623-8472

sureshcd10

Regular
Joined
Dec 25, 2003
Messages
77
I got Account Number=4549163506238472 .This Account number I want to get into format 4549-1635-0623-8472 .How can I do this ?Please help me.
I am using C#

Thanks in Advance
 
C#:
Console.WriteLine(new System.Text.RegularExpressions.Regex("([0-9]{4})").Replace("4549163506238472","$1-").TrimEnd('-'));

This assumes that the length of your string % 4 == 0.
 
I solved this issue by using the following.



StringBuilder sb = new StringBuilder(argstring);
sb.Insert(4,"-");
sb.Insert(9,"-");
sb.Insert(14,"-");
return sb.ToString;




Thank u all for their effort
 
Back
Top