How can I extract the following info from my string?
var text = "Test&NAME=XYZ&LANGUAGE=EN&COUNTRY=US"
To only XYZ
, EN
, US
in 3 separate variables?
How can I extract the following info from my string?
var text = "Test&NAME=XYZ&LANGUAGE=EN&COUNTRY=US"
To only XYZ
, EN
, US
in 3 separate variables?
Modifying the function provided in this answer gives a function that you can use to get the value of any parameter in an url:
function getURLParameter(url, parameter) {
return decodeURIComponent((new RegExp('[?|&]' + parameter + '=' + '([^&;]+?)(&|#|;|$)').exec(url)||[,""])[1].replace(/\+/g, '%20'))||null
}