let expr = "{{person.name}} --- {{person.age}}"; let flag = 0; let value = expr.replace(/\{\{(.+?)\}\}/g, (a,b,c,d,e) => { console.log(a,b,c,d,e); console.log('匹配到的字符串', a); console.log('回调函数返回替换的值', b); console.log('匹配字符串对应索引的位置', c); console.log('原始字符串--->', d); console.log(++flag); return 123; }); console.log('最后的返回值:', value);