function aaa()
{
//测试使用
var s1 = "f http://ubooo.com/test/123.html"
var s2 = " http://ubooo.com/test/123_2.html"
var reg = /\/([\d]+)(\.|[\d_]+\.)html/
var arr = s1.match(reg)
if (arr != null)
{
var url = " http://ubooo.com/Article.php?id=" + arr[1]
alert(url)
}//正常使用用以下代码
/*
var localUrl = location.href//获取当前URL地址
var reg = /\/([\d]+)(\.|[\d_]+\.)html/
var arr = localUrl.match(reg)
if (arr != null)
{
alert(1)
var url = " http://ubooo.com/Article.php?id=" + arr[1]
location.href = url//跳转
}
*/
}
</script>
<input type="button" value="测试" onclick="aaa()"/>
var url = 'xxxxxxxx.aspx?A=a&B=b&C=c'var result = url.match(/\?.*B=([^&]*).*/) // result为null或"",则url中不含B的值,否则result[1]即是参数B的值
上述代码,result[1] = b