Created
May 25, 2015 14:02
-
-
Save IUnknown68/a86d7eb7dcba77b6bef7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatS(s) { | |
var args = Array.prototype.slice.call(arguments); | |
var _replFn = function(all, before, index) { | |
return before + args[parseInt(index)]; | |
} | |
return s.replace(formatS._m, _replFn).replace('%%', '%'); | |
} | |
formatS._m = /([^%])%([0-9]+)/g; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment