Replace

Performs compile time string replacements on base

Members

Aliases

N
alias N = NextAt!(base, "", -1, -1, T)
Undocumented in source.

Manifest constants

Replace
enum Replace;
Undocumented in source.
Replace
enum Replace;
Undocumented in source.

Templates

NextAt
template NextAt(string base, string longest_spec, size_t _at0, size_t _ti0, T...)
Undocumented in source.

Parameters

T

replacement specs, alternating between string to be replaced and toStringNow-able object to replace with.

Examples

import std.stdio;

void main()
{
  string s = Replace!(q{$ret func(T)(T t){ return new $ret(t+$i); }},
    "$ret", "C",
    "$i", 5000);
  writeln(s); // "C func(T)(T t){ return new C(t+5000); }"
}

If there is ambiguity between two substrings to replace, the longer one is preferred:

enum s = Replace!("boy eats boysenberry", "boy", "girl", "boysenberry", "plum");
writeln(s) // "girl eats plum"

Meta