How is std.regex.replaceAllInto more efficient?

Shriramana Sharma via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 20 00:34:56 PDT 2015


Sönke Ludwig wrote:

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

Another option is to use KeepTerminator.yes. Using writeln() is shorter! :-)

So this one does avoids all the extra allocations due to use of *Into, then?

-- 
Shriramana Sharma, Penguin #395953


More information about the Digitalmars-d mailing list