Skip to content

Instantly share code, notes, and snippets.

@fearphage
Created November 15, 2009 03:38
Show Gist options
  • Select an option

  • Save fearphage/234959 to your computer and use it in GitHub Desktop.

Select an option

Save fearphage/234959 to your computer and use it in GitHub Desktop.
String.format = (function(slice) {
return function(template) {
var args = slice.call(arguments, 1), i = args.length;
while (i--) {
template = template.replace(new RegExp('\\{' + i + '\\}', 'g'), args[i]);
}
return template;
};
})(Array.prototype.slice);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment