function test(s) { var p = /[?&#]([a-zA-Z0-9]+)=([a-zA-Z0-9]*)/g, tmp, tmp2, result = {}; while(tmp = p.exec(s)) { tmp2 = tmp[2]; tmp2 = isNaN(tmp2) ? tmp2 : parseInt(tmp2); result[tmp[1]] = tmp2; } return result; }
另外提一嘴:jquery和正则表达式没有关系的
嗯,记住了,谢谢
<script type="text/javascript">
function getUrlPara(paraName){
var sUrl = location.href;
var sReg = "(?://?|&){1}"+paraName+"=([^&]*)"
var re=new RegExp(sReg,"gi");
re.exec(sUrl);
return RegExp.$1;
}
//应用实例:test_para.html?a=11&b=22&c=33
alert(getUrlPara("a"));
alert(getUrlPara("b"));
</script>
//截取参数然后去验证不行吗??
截取参数可以,但是比较麻烦,你上边的取值方式有点问题的,取出来的都是空值