我获取查询字符串的功能是:
GetID: function(name) {
return decodeURI((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1]);
},
当我得到一个网址时:
http://localhost/testsite/testB.aspx?ID=12
并调用这个函数它的 return 12。
但现在我的 url 模式发生了变化。
当前的网址格式是:
http://localhost/testsite/testB.aspx/12
现在我尝试更改正则表达式并替换?为/和其他东西以获得期望值12。
但我没有成功。我的知识regex不太好,所以帮助修改我的正则表达式以获得期望值。谢谢。