Selectively replace multiple instances of a character within a string: Difference between revisions
Selectively replace multiple instances of a character within a string (view source)
Revision as of 21:36, 28 July 2022
, 1 year ago→{{header|JavaScript}}
m (→Python) |
|||
Line 273:
const ds = a[c];
return
Object.assign(a, {[c]: ds.slice(1)}),
ds[0] || c
] : [a, c];
})() : [a, c]
)(Object.assign({}, ruleMap)
[...s]
)[1].join("");
// ---------------------- TEST -----------------------
const main = () =>
nthInstanceReplaced({
a: ["A", "B", null, "C", "D"],
|