Logo

Programming-Idioms

History of Idiom 63 > diff from v21 to v22

Edit summary for version 22 by :

Version 21

2015-11-01, 23:16:54

Version 22

2015-11-30, 12:37:30

Idiom #63 Replace fragment of a string

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

Idiom #63 Replace fragment of a string

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

Imports
uses
  SysUtils;
Imports
uses
  SysUtils;
Code
x2 := StringReplace(x, y, z, [rfReplaceAll]);
Code
x2 := StringReplace(x, y, z, [rfReplaceAll]);
Imports
import std.array;
Imports
import std.array;
Code
auto x2 = x.replace(y,z);  
Code
auto x2 = x.replace(y,z);  
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
Doc URL
http://dlang.org/phobos/std_array.html#.replace