Logo

Programming-Idioms

History of Idiom 63 > diff from v6 to v7

Edit summary for version 7 by :

Version 6

2015-08-20, 11:54:27

Version 7

2015-08-21, 01:03:46

Idiom #63 Replace fragment of a string

Assign to x2 the value of string x with all occurrences of y replaced by z.

Idiom #63 Replace fragment of a string

Assign to x2 the value of string x with all occurrences of y replaced by z.

Imports
import std.stdio;
import std.array;
Code
void main()
{
	auto x = "111122223333";
	auto y = "22";
	auto z = "555";

	auto x2 = x.replace(y,z);  

        writeln(x2);

}
Comments bubble
same as
auto x2 = replace(x,y,z)
but easier to guess operation in this form
Origin
http://dlang.org/phobos/std_array.html#.replace