Logo

Programming-Idioms

History of Idiom 63 > diff from v12 to v13

Edit summary for version 13 by :

Version 12

2015-08-23, 10:56:56

Version 13

2015-09-03, 17:13:04

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.

Code
x2 = x.gsub(y, z)
Doc URL
http://ruby-doc.org/core-2.2.3/String.html#method-i-gsub