SOURCE

var winTitle = ' 恭喜您,获得$title$,奖品为$name$';
var reg=/(\w*)\$title\$(.*)\$name\$(.*)/g;
console.log(winTitle.replace(reg,"$1一等奖$2小米手环"));
    
console 命令行工具 X clear

                    
>
console