Logo

Programming-Idioms

History of Idiom 63 > diff from v56 to v57

Edit summary for version 57 by doinkythederp:
New JS implementation by user [doinkythederp]

Version 56

2021-12-20, 11:43:09

Version 57

2022-01-23, 00:00:35

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.

Variables
x2,x,y,z
Variables
x2,x,y,z
Extra Keywords
substring substitute
Extra Keywords
substring substitute
Code
const x2 = x.replaceAll(y, z);
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll