//"{0}-{1}-{2}".format("xx","yy","zz")
//显示xx-yy-zz
String.prototype.format = function() {
var result=this;
if (arguments.length == 0)
return null;
for ( var i = 0; i < arguments.length; i++) {
var re = new RegExp('\\{' + (i) + '\\}', 'gm');
result = result.replace(re, arguments[i]);
}
return result;
};
扩展js,实现c#中的string.format方便拼接字符串
本文转载:CSDN博客