I am trying to get query and filter value from this url:
http://xyz/search.page?query=apple&filter=all
using this function:
getParameters: function(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(([^&#]*)=|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(unescape(results[2].replace(/\+/g, " ")));
}
It will return query=apple for this but if we have value like apple# or apple& it will not consider those special character it will still return apple. but for all the rest of special character like !,@,* this will return apple! or apple@ etc. Can someone help me getting proper result for # and & also, Thanks in advance.