Here you can find the source of format()
String.prototype.format = function() { var formatted = this; for (arg in arguments) { formatted = formatted.replace('{' + arg + '}', arguments[arg]); }/*from ww w.j a v a 2 s. c o m*/ return formatted; };
String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };
String.prototype.format = function() { var placeholderREG = /\{(\d+)\}/g; var args = arguments; return this.replace(placeholderREG, function(holder, num) { return args[num]; });
String.prototype.format = function() { var formatted = this; for( var arg in arguments ) { formatted = formatted.replace("{" + arg + "}", arguments[arg]); return formatted; }; function assert(condition, msg) { if (!condition) { ...
'use strict'; String.prototype.format = function () { var args = arguments; return this.replace(/\{(\d+)\}/g, function (m, n) { return args[n]; }); }; String.prototype.escapeRegExp = function () { return this.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); ...
String.prototype.format = function() { var source = this; for (var i = 0; i <= arguments.length - 1; i++) { var reg = new RegExp("\\{" + i + "\\}", "gm"); source = source.replace(reg, arguments[i]); return source; }; Date.prototype.format = function (fmt) { ...
String.prototype.format = function() { var args = arguments; return this.replace(/\{(\d+)\}/g, function(m, i) { return args[i]; }); }; String.prototype.encodeHTML = function () { var s = this.valueOf(); ...
String.format = function () { var s = arguments[0]; for (var i = 0; i < arguments.length - 1; i++) { var reg = new RegExp("\\{" + i + "\\}", "gm"); s = s.replace(reg, arguments[i + 1]); return s; String.prototype.format = function () { ...
String.prototype.format = function () { var args = arguments; var reg = /\{(\d+)}/g; return this.replace(reg, function (g0, g1) { return args[+g1]; }); }; var str = "this is :{0} and {1} , and {0}".format("arg1","arg2") var main = "Scripts/main"; ...
String.prototype.format = function(){ var re_all = /{(\d+)?(:(\d+)?(.\d+?f))?}/g; var re_index = /(\d+):/; var re_before = /(\d+)\./; var re_after = /\.(\d+)/; var cur = this; var matches = cur.match(re_all); if (arguments.length > matches){ console.log("Too many arguments!"); ...