I used that solution:

string InsertComma(string val)
{
        return val[0 .. $-2] ~ "," ~ val[$-2 .. $];
}

On Thursday, 10 July 2014 at 16:23:44 UTC, John Colvin wrote:
On Thursday, 10 July 2014 at 16:05:51 UTC, Alexandre wrote:
I have a string X and I need to insert a char in that string...

auto X = "100000000000000";

And I need to inser a ',' in position 3 of this string..., I try to use the array.insertInPlace, but, not work...

I try this:
auto X = "100000000000000";
auto N = X.insertInPlace(1,'0');

insertInPlace works like this:

auto X = "100000000000000";
auto X1 = X;
X.insertInPlace(3, ',');
assert(X == "100,000000000000");
assert(X1 == "100000000000000");


You can also do this:

auto X = "100000000000000";
auto N = X[0 .. 3] ~ ',' ~ X[3 .. $];
assert(X == "100000000000000");
assert(N == "100,000000000000");

Reply via email to