Substitutes substrings.
https://www.npmjs.com/package/@pelevesque/substitute-substrings
npm install @pelevesque/substitute-substrings
npm test
npm run cover
const substituteSubstrings = require('@pelevesque/substitute-substrings')const str = 'abbc'
const substitutions = ['b', '2']
const result = substituteSubstrings(str, substitutions)
// result === 'a22c'Substrings are not swapped like with https://github.com/pelevesque/swap-substrings
const str = 'ac'
const substitutions = ['a', 'c']
const result = substituteSubstrings(str, substitutions)
// result === 'cc'const str = 'abbcabcc'
const substitutions = [
['a', '1'],
['b', '2'],
['c', '3']
]
const result = substituteSubstrings(str, substitutions)
// result === '12231233'const str = 'a long stormy night and a little boy named jim'
const substitutions = [
['a ', 'the '],
['night', 'day'],
['jim', 'oscar'],
['long', 'short'],
['little', 'very tall']
]
const result = substituteSubstrings(str, substitutions)
// result === 'the short stormy day and the very tall boy named oscar'