Am 17.10.2015 um 12:06 schrieb Shriramana Sharma:
Dmitry Olshansky wrote:

Feel free to improve on the examples, I'd gladly pull such patches.

How about this, using the "comifying" regex from the replaceAll example:

     auto re = ctRegex!(`(?<=\d)(?=(\d\d\d)+\b)`, "g");
     auto sink = appender!(char [])();
     foreach (line; stdin.byLine())
     {
         sink.clear();
         replaceAllInto(sink, line, re, ",");
         writeln(sink.data());
     }


How about going one step further:

    auto re = ctRegex!(`(?<=\d)(?=(\d\d\d)+\b)`, "g");
    foreach (line; stdin.byLine())
    {
        replaceAllInto(stdout.lockingTextWriter, line, re, ",");
        writeln();
    }

Reply via email to