const str = "ie=utf-8&f=&rsv_bp=1 &rsv_idx&tn=baidu&wd=sql&rsv_pq=c5fd80d0000f079a&rsv_enter=1&"
const re = /(\w+)=?([^=&]+)?&?/g
let json = {}
str.replace(re, function (x1, x2, x3) {
json[x2] = x3 ? escape(x3.trim()) : ''
})
console.log(json)
结果: