What's the most efficient way to format the following string?
Posted
by Ian P
on Stack Overflow
See other posts from Stack Overflow
or by Ian P
Published on 2010-05-20T17:51:51Z
Indexed on
2010/05/20
18:00 UTC
Read the original article
Hit count: 278
I have a very simple question, and I shouldn't be hung up on this, but I am. Haha!
I have a string that I receive in the following format(s):
123
123456-753
123455-43
234234-4
123415
The desired output, post formatting, is:
123-455-444
123-455-55
123-455-5
or
123-455
The format is ultimately dependent upon the total number of characters in the original string..
I have several ideas of how to do this, but I keep thing there's a better way than string.Replace and concatenate...
Thanks for the suggestions..
Ian
© Stack Overflow or respective owner