www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - CTFE using of replaceAll from std.regex posible?

reply Martin Tschierschke <mt smartdolphin.de> writes:
when trying to process an string at compile time with
  auto reg = ctRegex!`as\ [a-z]+`;
  enum replaced = replaceAll(call,reg,"");

I get:
/usr/include/dmd/phobos/std/regex/package.d(708,34): Error: 
malloc cannot be interpreted at compile time, because it has no 
available source code
called from here: enforce(malloc(size), delegate const(char)[]() 
=> "malloc failed", 
"/usr/include/dmd/phobos/std/regex/package.d", 708LU)
called from here: ((RegexMatch!(string, BacktrackingMatcher) 
__slRegex3165 = RegexMatch(BacktrackingMatcher(Regex(null, null, 
null, 0u, 0u, 0u, 0u, 0u, null, null, null, ShiftOr(null, 0u, 
0u)), null, Input(null, 0LU), 0LU, '\U0000ffff', false, 0u, 0u, 
0LU, null, null, null, null), null, Captures(null, 0, null, , 0u, 
0u, 0u, null), null);) , __slRegex3165).this(input, re)
called from here: matchMany(input, re)
called from here: matchAll(input, re)
called from here: replaceAllWith(input, re)
src/app.d(13,29):        called from here: replaceAll(call, reg, 

It there a way to use "replaceAll" at compile time?

Regards mt.
Apr 12
parent Stefan Koch <uplink.coder googlemail.com> writes:
On Wednesday, 12 April 2017 at 12:00:27 UTC, Martin Tschierschke 

 It there a way to use "replaceAll" at compile time?

 Regards mt.
Not yet :) I assume it would bring the current system to it's needs. I you want to experiment you could replace malloc with new.
Apr 12