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 address = '辽宁省沈阳市和平区' // 以这个地址为例var proExp = '.+[省]', cityExp = '.+[市]', disExp = '.+[区]'
var province = address.match(new RegExp(proExp)) // 省
var city = address.match(new RegExp(cityExp))[0].replace(province, '') // 市
var district = address.match(new RegExp(disExp))[0].replace(province, '').replace(city, '') // 区