Skip to content

Instantly share code, notes, and snippets.

@spideron
Created February 7, 2013 19:36
Show Gist options
  • Select an option

  • Save spideron/4733528 to your computer and use it in GitHub Desktop.

Select an option

Save spideron/4733528 to your computer and use it in GitHub Desktop.
string format (C like)
String.prototype.wiFormat = function () {
var pattern = /\{\d+\}/g;
var args = arguments;
return this.replace(pattern, function (capture) {
return args[capture.match(/\d+/)];
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment