SOURCE

let ipt = '${abc} 8jfj ${def} opsdjl';
const vars = ipt.match(/\$\{.*?\}/g);
const res = vars.reduce((fin, item) => (fin[item] = prompt(item), fin), {});
console.log(ipt.replace(/\$\{.*?\}/g, w => res[w]));
console 命令行工具 X clear

                    
>
console