Skip to content

Instantly share code, notes, and snippets.

@aseredenko
Last active February 22, 2018 12:14
Show Gist options
  • Save aseredenko/a91beaf54aa0f2b128259e197887d81f to your computer and use it in GitHub Desktop.
Save aseredenko/a91beaf54aa0f2b128259e197887d81f to your computer and use it in GitHub Desktop.
function gup( name, url ) {
if (!url) url = location.href;
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( url );
return results == null ? null : results[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment