@ananay-nag/text-formatter
Version:
This README would normally document whatever steps are necessary to get your application up and running.
25 lines (24 loc) • 670 B
JavaScript
const blManager = {
replaceObject,
};
function replaceObject(text, objectData) {
let str = text;
let res = str.match(/{(\w+)}/gi);
for (var index = 0; index < res.length; index++)
str = str.replace(
res[index],
objectData[res[index].replace("{", "").replace("}", "")]
);
return str;
}
// function replaceArray(text, arrayData) {
// let str = text;
// let res = str.match(/{(\w+)}/gi);
// for (var index = 0; index < res.length; index++)
// str = str.replace(
// res[index],
// objectData[res[index].replace("{", "").replace("}", "")]
// );
// return str;
// }
module.exports = blManager;