Skip to content

Instantly share code, notes, and snippets.

@0i0
Created Dec 25, 2011
Embed
What would you like to do?
javascript snippets
function getCookie(key){
var regEx = new RegExp(key+"=([^;]*)","g");
return regEx.exec(document.cookie)[1]
}
String.prototype.format = function () {
var args = arguments;
return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function (curlyBrack, index) {
return ((curlyBrack == "{{") ? "{" : ((curlyBrack == "}}") ? "}" : args[index]));
});
};
"{0}{1}".format("{1}", "{0}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment