Logo

Programming-Idioms

History of Idiom 63 > diff from v8 to v9

Edit summary for version 9 by :

Version 8

2015-08-21, 23:30:21

Version 9

2015-08-21, 23:31:26

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;
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);

}
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
Comments bubble
same as
auto x2 = replace(x,y,z)
but easier to guess operation in this form
Doc URL
http://dlang.org/phobos/std_array.html#.replace
Origin
http://dlang.org/phobos/std_array.html#.replace