Пример #1
0
    private static string Delimit(this string valueString, string delimiter, uint delimitCount)
    {
        delimitCount.AssertPositive();
        delimiter.IsNormalized().AssertTrue();

        delimiter = delimiter.Reversed();

        string result = "";

        char[] reversedString = valueString.ToCharArray().Reverse();
        for (int i = 0; i < reversedString.Length; ++i)
        {
            if (i != 0 && Char.IsNumber(reversedString[i]) && (i % delimitCount) == 0)
            {
                result += delimiter;
            }
            result += reversedString[i];
        }

        return(result.Reverse().Normalize());
    }