补充一点:必须是以http://开头(不区分大小写)

解决方案 »

  1.   

    go to 
    http://www.regexlib.com/Default.aspxtype "url" in the keyword textbox, click on "Search" button, pick one you like
      

  2.   

    <script>
    function test(url){
    return(/^http:\/\/[\w\.\/]+\.(zip|exe|rar)$/.test(url));
    }
    alert(test("http://www.blahblahblah.com/fadefile.php?id=123.zip"));
    alert(test("http://www.blahblahblah.com/123.zip"));
    </script>
      

  3.   

    <script>
    function testThisURL(strVal){
    var s = strVal.toLowerCase(); // 转换小写
    // txtFile为空: (^[\s]+$)
    // txtFile包含?、 &、 .htm、.html、.asp、.php等字符或字符串: (\?)|(\&)|(\.htm)|(\.html)|(\.asp)|(\.php)
    // txtFile以.zip/.exe/.rar结尾(不区分大小写): (\.zip)|(\.exe)|(\.rar)$
    // 以http://开头 ^http:\/{2}
    var r = false;
    if(s.match(/^[\s]+$/))r=false; // 不为空
    else if(s.match(/(\?)|(\&)|(\.htm)|(\.html)|(\.asp)|(\.php)/))r=false; // 不包含它们
    else if(!s.match(/^http:\/{2}.+(\.zip)|(\.exe)|(\.rar)$/))r=false;  // 必须包含 http:// 必须以他们结尾
    return r;
    }</script>