Node.js examples for String:Format
Format function that replace placeholders in strings with values
/**//from w ww . j av a 2s .c o m * Format function that replace placeholders in strings with values * Usage : "This is {0} formatted {1}".format("a", "string"); **/ String.prototype.format = function() { var formatted = this; for(var i = 0; i < arguments.length; i++) { var regexp = new RegExp('\\{' + i + '\\}', 'gi'); formatted = formatted.replace(regexp, arguments[i]); } return formatted; };