How can a JavaScript regular expression be written to separate a URI into query string variables, where the variables itself might contain the '&' character?
I'm currently using the following code- but if any of the variables contain an & embedded it won't capture the rest of that variable. How can this be alleviated?
function uriParameters() {
  var vars = {};
  var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
    vars[key] = value;
  });
  return vars;
}
 
     
     
    