string-replacer
1.0.2 • Public • Published string-replacer
strReplacer#replace
str
- target string to be replace.
regexp
- A RegExp object.
iterator
- A function to be invoked to create the new substring.
let content = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
let reg = /[A-Y]/g;
let str = strSplicer.replace(content, new RegExp(reg), (match)=> {
return match[0] + '-';
});
strReplacer#replaceAsync
str
- target string to be replace.
regexp
- A RegExp object.
iteratorAsync
- A function to be invoked with the new substring callback.
done
- invoked until no more substring matches by regexp
in str
let content = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
let reg = /[A-Y]/g;
strSplicer.replaceAsync(content, new RegExp(reg), iteratorAsync(match, cb)=> {
cb(null, match[0] + '-');
}, (err, str)=> {
});
Package Sidebar
Install
Weekly Downloads