function getPlaceholder(url){
let reg = /\$\{(.+?)\}/;
let reg_g = /\$\{(.+?)\}/g;
let result = url.match(reg_g);
let valueArr = [];
for(let i=0;i<result.length;i++){
valueArr.push(result[i].match(reg)[1]);
}
console.log(result);// ["${a}","${b}"];
console.log(valueArr);// ["a","b"];
}
getPlaceholder('https://www.baidu.com?a={a}&b={b}');
06-12
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交