let obj = {
orgIntraCode: "111",
content: "222",
};
let a = /{(.+?)}/g;
let b = "url?zzzz={orgIntraCode}&kkk={content}";
let c = b.match(a);
let ss =b
if (c) {
for (var i = 0; i < c.length; i++) {
let strs = c[i].replace(a, "$1")
let newStr = obj[strs]
if (newStr) {
ss = ss.replace(c[i], newStr);
} else {
ss =ss.replace(c[i], "");
}
}
}
console.log(ss);
网友评论