本帖最后由 qq172108810 于 2010-05-31 16:18:21 编辑

解决方案 »

  1.   

    <script>
        var link="http://www.ubooo.com/test/123.html";
        var rtn=link.match(/\d+/);
        alert(rtn);
    </script>
      

  2.   

    <script>
        var link="http://www.ubooo.com/test/123.html";
        var rtn=link.substring(link.lastIndexOf("/")+1);
        rtn=rtn.match(/[^_.]+/);
        alert(rtn);
    </script>
      

  3.   

    var str=["http://www.ubooo.com/test/123.html","http://www.ubooo.com/test/123_2.html"];document.write((str[0].match(/.*\/(\d+)\.\w+/)||[0,""])[1]);
    document.write("<br/>");
    document.write((str[1].match(/.*\/([\d_]+)\.\w+/)||[0,""])[1]);
    document.write("<br/>");
    document.write((str[1].match(/.*\/(\d+)\_\d+\.\w+/)||[0,""])[1]);