String.format = function()
{
if ( arguments.length == 0 )
{
return null;
}
var str = arguments[0];
for(var i=1;i
{
var re = new RegExp('\{' (i-1) '\}','gm');
str = str.replace(re, arguments[i]);
}
return str;
}
Usage: String.format('Hello. My name is {0} {1}.', firstName, lastName);