I need to extract url parameters from the following string
?theAccount=someData&theToken=sometoken&mediaId=someid
so I want someData sometoken someid
here is the function I am using
function getParams( name ) {
var str = window.location.search;
var r = new RegExp("/(^\?|&+)"+name+"(\=)/");
var result = r.exec(str);
if (r) { return result; }
return "";
}
called like so getParams(theAccount);
But it's not working and keeps "invalid regular expression". Any help is much appreciated.