Skip to content

Instantly share code, notes, and snippets.

@GingerBear
Created January 14, 2014 22:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GingerBear/8427464 to your computer and use it in GitHub Desktop.
Save GingerBear/8427464 to your computer and use it in GitHub Desktop.
JavaScript URL parameters parsing by Regular Expression
function url_param(url) {
var _url = url || window.location.href;
var array = _url.match(/\w+=\w+/g);
var result = {};
var tmp = [];
for (var i = 0; i < array.length; i++) {
tmp = array[i].split("=");
result[tmp[0]] = tmp[1];
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment