-6

aa=&bb=0108135719&cc=20180108135935&dd=ee&ff=201801081358544265&gg=1&hh=1000&ii=&

i have a string like this and i trying to get specific value from it, it is in text format. what can i do if i want to get value of 'aa' it null and value of 'bb' it is 0108135719 tats it. I'm tried different regex but unable to get the desired output.

1 Answers1

1

You can do something like

var t="aa=&bb=0108135719&cc=20180108135935&dd=ee&ff=201801081358544265&gg=1&hh=1000&ii=&".split("&")
console.log(t)
var ansObj = {}

t.forEach((element) => {
const elementArray = element.split("=")
const key = elementArray[0]
const value = elementArray[1]
ansObj[key] = value
})
console.log(ansObj)
simbathesailor
  • 3,681
  • 2
  • 19
  • 30