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 }
String.prototype.formatWith
原文:http://www.cnblogs.com/lizhanglong/p/6897869.html