Skip to content

Instantly share code, notes, and snippets.

@simshanith
Created April 5, 2013 15:53
Show Gist options
  • Save simshanith/5320409 to your computer and use it in GitHub Desktop.
Save simshanith/5320409 to your computer and use it in GitHub Desktop.
Pull name/value pairs from URL query string
function querystring(key) {
var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
var r=[], m;
while ((m=re.exec(document.location.search)) != null) r.push(m[1]);
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment