0

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?

Alex K.
  • 165,803
  • 30
  • 257
  • 277

1 Answers1

0

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
}
Community
  • 1
  • 1
NotABlueWhale
  • 765
  • 7
  • 18