Javascript String format(values)
String.prototype.format = function (values) { var string = this; for (var key in values) if (values.hasOwnProperty(key)) { var regex = new RegExp("{" + key + "}", "g"); string = string.replace(regex, values[key]); }//from w w w . j a va2 s. com return string; };