How does js use rules to find the content specified in the string

1. The string str= "zz=aaa,bb=bbb,cc=ccc;User=ZZZ&zz=aaa1&bb=bbb1&cc=ccc1"
2. To implement, for example, I pass in the parameter zz, and find the value of aaa1 in the zz=aaa1 after User=ZZZ. How to write the corresponding rule?


/User=ZZZ.*zz=(\w+)/

str="zz=aaa,bb=bbb,cc=ccc;User=ZZZ&zz=aaa1&bb=bbb1&cc=ccc1";
    function find(str){
        var reg=/([^?=&]+)=([^?=&]+)/g;
        var result=null;
        var o={};
        while((result=reg.exec(str))!=null){
            o[result[1]]=result[2];
        }
        return function getByName(name){
            return o[name];
        }
    }
    var s=find(str);
    console.log(s('zz'),s('cc'));

because you don't have an accurate description of the problem, the specification written by others may not be appropriate.


function getValue(str,filed){
var regex=new RegExp("&"+filed+"=([^&]*)","g");
var match=null;
var result=[];
while((match=regex.exec(str))!=null){
    result.push(match[1]);
}
return result;
}

var str="zz=aaa,bb=bbb,cc=ccc;User=ZZZ&zz=aaa1&bb=bbb1&cc=ccc1";
var filed="zz";
getValue(str,filed);

var str="zz=aaa,bb=bbb,cc=ccc;User=ZZZ&zz=aaa1&bb=bbb1&cc=ccc1";
var reg = /User=ZZZ&zz=(\w+)/;
var reg2 = /User=.*&zz=(\w+)/;   //User

reg.exec(str)[1];     //aaa1
reg2.exec(str)[1];    //aaa1
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e83390-c3a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e83390-c3a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?