let reg =/([^?&+#]+)=([^?&+#]+)/g; let obj={}; let href = 'http://www.runoob.com/jquery/misc-trim.html?channelid=12333&name=xiaoming&age=23'; href.replace(reg,($0,$1,$2)=>obj[$1]=$2) console.log(obj);