For example,I have an input of "cid=5",and the output of this function is an array({cid=5,,5}).I'm confused about the result.Could someone help me to explain this question?
function getParameter(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
var r = location.search.substr(1).match(reg);
if (r!=null) return (r[2]); return null;
}
Thanks for the comment below,but I still confused about this question.So,I will try to express my question more clearly. The second parameter of the RegExp object is 'i',that means ignore case and it will match once and return a String object.So why it return a String array like{cid=5,,5,}?