String.prototype.formatWith

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     }

 

posted on 2017-05-24 11:02  木龙哥  阅读(293)  评论(0编辑  收藏  举报

导航