xxxxxxxxxx
void main()
{
import std.regex;
import std.stdio: write, writeln, writef, writefln;
// insert comma as thousands delimiter
auto re = regex(r"(?<=\d)(?=(\d\d\d)+\b)", "g");
writeln(replaceAll("12000 + 42100 = 54100", re, ",")); // "12,000 + 42,100 = 54,100"
}