Created
March 19, 2016 14:51
-
-
Save GitHub30/7bd0dacddf4ffb0b00ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
String.prototype.f = function(arg){ | |
var args = typeof arg === 'object' ? arg : arguments, | |
keys = Object.keys(args).map(function(s){return s.replace(/\\|\(|\)|\|/g,'\\$&');}).join('|'); | |
return this.replace(new RegExp('\\{('+keys+')\\}', 'gm'), function(match, key){return args[key];}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment