I have a string that has parameters separated with ampersands , for example :
orderid=55e3a83e&DealId=545435&Amount=590 ....
How can I convert that into a Key/Value Map ?
My current code is as follows :
const text = "orderid=55e3a83e&DealId=545435&Amount=590 ...."
let _key = "";
let _value = "";
var myregexp = /([^&=]+)=(.*?)(?=&[^&=]+=|$)/g;
var match = myregexp.exec(text);
while (match != null && key !== "url") {
_key = match[1];
_value = match[2];
dict.push({
key: _key,
value: _value
});
match = myregexp.exec(subject);
}
But it's too long , any idea for something better or shorter ?