On 17-Oct-2015 13:06, Shriramana Sharma wrote:
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());
}
My problem with it is writeln/byLine b/c it can't be unittested.
Documented unit-tests as examples are gold.
On the other hand you can post it to list of example shown on the first
page of dlang.org because I think it's kind of cool.
Also a variation of this example can be put in std.regex synopsis.
--
Dmitry Olshansky