functions that match parameters in url in js on the Internet
function getQueryString(name){
var reg = new RegExp("(^|&)"+name+"=([^&]*)(&|$)");
var href = window.location.href
var index = href.indexOf("?")
var r = href.substr(index+1).match(reg);
if(r != null)
return unescape(r[2]);
return null;
}
I see the explanation that the first (^ | &) is ^ or & or none, (& | $) is & or $or none;
but I try to start with ^ and it won"t match.
so I understand that ^ here is the beginning and $is the end.
if so | & how to understand, or whether it is possible to write ^ (&), | meaningless. This returns null.
I finally tried ^ (| &) "+ name+" = (< sup id= "fnref-1" > 1 < / sup > *) (& |) $, and the returned result is consistent with the source code.
so | what is the effect, is there no or &?