http://www.bvbuy.cn/ProductsHtml/products80.html用什么更好的方法 提取 80出来。数字位数不定。

解决方案 »

  1.   

    var str ="http://www.bvbuy.cn/ProductsHtml/products80.html";
    alert(str.match(/\d+/g));
      

  2.   

    楼上正解!正则表达即可!
    ar str ="http://www.bvbuy1111.cn/Products2222Html/products80.html";
    var arr=str.match(/\d+/g);
    得到数组【1111,2222,80】
      

  3.   

    reg = /^.*\/[^\d]*(\d*)[^\d]*\..*$/g"http://www.bvbuy.cn/ProductsHtml/products80.html".replace(reg,"$1")"http://www.bvbuy.cn/ProductsHtml/products80dwwd.html".replace(reg,"$1")"http://www.bvbuy.cn/ProductsHtml/80dwwd.html".replace(reg,"$1")"http://www.bvbuy.cn/ProductsHtml/80.html".replace(reg,"$1")
      

  4.   

    "http://www.bvbuy111.cn/Products222Html/fdfd80fdfd.html".replace(reg,"$1")
      

  5.   

    除了正则表达式,利用substring,splite等字符串操作方法针对ascii码比较也是可以实现的
      

  6.   


    match(/\d+/g)//正则吧,比较方便