解决方案 »

  1.   

    'http://www.xxxxx.com/dfd646d4f6dffd/你好.jpg'.match(/^(.+?\/)+/i)[0]
      

  2.   

    'http://www.xxxxx.com/dfd646d4f6dffd/你好.jpg'.match(/[\w\W]+\//)
      

  3.   

    "http://www.xxxxx.com/dfd646d4f6dffd/你好.jpg".replace(/[^/]*$/g,"")
      

  4.   

    function IsURL(str_url){
      var strRegex = "^((https|http|ftp|rtsp|mms)?://)" 
      + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?"  
            + "(([0-9]{1,3}\.){3}[0-9]{1,3}" 
            + "|" // 允许IP和DOMAIN(域名)
            + "([0-9a-z_!~*'()-]+\.)*" // 域名- www. 
            + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名 
            + "[a-z]{2,6})" // first level domain- .com or .museum 
            + "(:[0-9]{1,4})?" // 端口- :80 
            + "((/?)|" // a slash isn't required if there is no file name 
            + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; 
            var re=new RegExp(strRegex); 
      //re.test()
            if (re.test(str_url)){
                return (true); 
            }else{ 
                return (false); 
            }
        } 
      

  5.   


    function IsURL(str_all){
      var strRegex = "^((https|http|ftp|rtsp|mms)?://)" 
      + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?"  
            + "(([0-9]{1,3}\.){3}[0-9]{1,3}" 
            + "|" // 允许IP和DOMAIN(域名)
            + "([0-9a-z_!~*'()-]+\.)*" // 域名- www. 
            + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 
            + "[a-z]{2,6})" // first level domain- .com or .museum 
            + "(:[0-9]{1,4})?" // 端口-  
            + "((/?)|" // a slash isn't required if there is no file name 
            + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$"; 
            var re=new RegExp(strRegex); 
      //re.test()
            if (re.test(str_url)){
                return (true); 
            }else{ 
                return (false); 
            }
        }   
      

  6.   

    'http://www.xxxxx.com/dfd646d4f6dffd/你好.jpg'.match(/^.+\/(?=[^\/?#]+)/)