Parsing an URL in JavaScript

前端 未结 3 990
说谎
说谎 2021-01-23 12:11

I need to parse url in JavaScript.

Here is my code:

var myRe = /\\?*([^=]*)=([^&]*)/;
var myArray = myRe.exec(\"?page=3&Name=Alex\");


for(var i         


        
3条回答
  •  情歌与酒
    2021-01-23 12:57

    var qs="da?page=3&page=4&Name=&xxx=43&page=&#adasdsadsa";
    var params=qs.replace(/^.*\??/g,'').replace(/#.*/g,'').match(/[^&\?]+/g);
    var args={};
    if(params)for(var i=0;i

提交回复
热议问题