1 String.prototype.formatWith = function () { 2 var args = arguments; 3 var reg = /\{(\d+)\}/g; 4 return this.replace(reg, function (g0, g1) { 5 return args[+g1] || ‘‘; 6 }); 7 }
时间: 2024-12-08 18:23:51
1 String.prototype.formatWith = function () { 2 var args = arguments; 3 var reg = /\{(\d+)\}/g; 4 return this.replace(reg, function (g0, g1) { 5 return args[+g1] || ‘‘; 6 }); 7 }