var String = "https://www.google.com/abc/xyz?firstQp=5&firstQp=IamMaster";
var firstQp = "";
var secondQp = "";
var mainString = String.split("?");
var queryparams = mainString[1].split("&");
for (i = 0; i<2; i++) {
var queryparam = queryparams[i].split("=");
if (queryparam[0].indexOf("firstQp") != -1)
firstQp = queryparam[1];
if (queryparam[0].indexOf("secondQp") != -1)
secondQp = queryparam[1];
}
No. my requirement was to use it in a javascript. Its not part of request query parameters. Please check the solution that I designed below to meet this requirement.
URL parsing can be a beast. If your URLs are always very consistent like above, rolling your own isn’t so bad. If that url string might vary a bit, I recommend looking at URI.js (https://medialize.github.io/URI.js/). It’s easy to include it as a resource for your js scripts and it handles everything I’ve needed to throw at it.