-
Notifications
You must be signed in to change notification settings - Fork 1
map replace
Subhajit Sahu edited this page May 5, 2020
·
1 revision
Replace parts of string using map.
const mapReplace = require('@extra-string/map-replace');
// mapReplace(<string>, <map>)
mapReplace('alpha beta', new Map().set('alpha', 'α').set('beta', 'β'));
// 'α β'
mapReplace('gamma DELTA', new Map().set('gamma', 'γ').set('delta', 'δ'));
// 'γ DELTA'
mapReplace('Epsilon ZETA', new Map().set(/epsilon/gi, 'ε').set(/zeta/gi, 'ζ'));
// 'ε ζ'