Selectively replace multiple instances of a character within a string: Difference between revisions

m
Line 272:
// the nth instances of various characters.
s => mapAccumL(
(a, c) => c in ruleMapa ? (() => {
const ds = a[c];
i = a[c] || 0,
ds = ruleMap[c];
 
return 0 < ds.length ? [
Object.assign(a, {[c]: ds.slice(1 + i)}),
i < ds.length[0] ?|| (c
] : ds[i] ||a, c];
) : c
];
})() : [a, c]
)({}ruleMap)([...s])[1].join("");
 
 
9,655

edits