How is std.regex.replaceAllInto more efficient?

Marc Schütz via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 17 04:16:28 PDT 2015


On Saturday, 17 October 2015 at 10:54:19 UTC, Dmitry Olshansky 
wrote:
> 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.
>

You can prefix it with `version(StdDdoc)`, then it will only 
appear in the documentation. It won't be really tested of course, 
but the compiler will at least do syntax checking on it, I guess.


More information about the Digitalmars-d mailing list