Skip to content

Instantly share code, notes, and snippets.

@simon-engledew
Last active December 26, 2015 08:59
Show Gist options
  • Save simon-engledew/7126458 to your computer and use it in GitHub Desktop.
Save simon-engledew/7126458 to your computer and use it in GitHub Desktop.
String.format
String.format = function format()
{
var replacements = arguments;
return arguments[0].replace(/\{(\d+)\}/gm, function replace(string, match) {
return replacements[parseInt(match) + 1];
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment