以前也是用replace方法的,但今天才知道原来replace方法的第二个参数可以是函数!
"Student {name}'s age is ${age}".replace(/\{(\w+)\}/g, function(a, b) {console.log(a + ',' + b);})