Skip to content

Instantly share code, notes, and snippets.

@ccwq
Created November 12, 2016 08:32
Show Gist options
  • Save ccwq/88c8dc13495d2be51a97ff2f6b3b2840 to your computer and use it in GitHub Desktop.
Save ccwq/88c8dc13495d2be51a97ff2f6b3b2840 to your computer and use it in GitHub Desktop.
/**
* 根据某目录名分割路径
* ex:split_path
* @param path 要切割的路径
* @param str1 按照可能存在的目录顺序传入参数
* @param strn
* @param ...
*/
function split_path(path,str1,strn){
var ret,str, strlist = Array.prototype.slice.call(arguments,1);
while(str=strlist.shift()) {ret = path.split(str)[0];}
return ret==path?"":ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment