Ask the old SJ to write a paragraph to regularly match the parameters specified in the string.

str = "http://bbs.aa.cc/avatar.php?uid=157135&size=large"

"

I want to match uid=157135,
and the position where this parameter appears is not necessarily fixed.
for example, put at the end: http://bbs.aa.cc/avatar.php?s.
or first


function GetQueryString (name) {

var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;

}

GetQueryString ('uid')


  http://regex.zjmainstay.cn/r/.

Menu