List of utility methods to do String Format
format()String.prototype.format = String.prototype.format = function() { var s = this, i = arguments.length; while (i--) { s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); return s; }; | |
format()define(function () { return { currentDate: function () { var date = new Date(); var dd = date.getDate(); var mm = date.getMonth() + 1; var yyyy = date.getFullYear(); var hh = date.getHours(); var MM = date.getMinutes(); ... | |
format()String.prototype.format = function () { var o = Array.prototype.slice.call(arguments); return this.replace(/{([^{}]*)}/g, function (match, capture) { var r = o[capture]; return (typeof r === 'string' || typeof r === 'number') ? r : match; ); }; ... | |
format()String.prototype.format = function() { var args = arguments; return this.replace(/\{(\d+)\}/g, function(orig,num) { return typeof args[num] != 'undefined' ? args[num] : orig; }); }; | |
format()String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); }; | |
format()String.prototype.format = function() { var placeholderREG = /\{(\d+)\}/g; var args = arguments; return this.replace(placeholderREG, function(holder, num) { return args[num]; }); | |
format()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) { ... | |
format()'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"); ... | |
format()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) { ... | |
format()String.prototype.format = function() { var formatted = this; for (arg in arguments) { formatted = formatted.replace('{' + arg + '}', arguments[arg]); return formatted; }; |