关于过滤文件路径的正则表达式

在js中 过滤文件路径的正则 怎么写?求指教 希望全面点

public static bool CheckPath(string path)
{
    string pattern = @"^[a-zA-Z]:(((\\(?! )[^/:*?<>\""|\\]+)+\\?)|(\\)?)\s*$";
    Regex regex = new Regex(pattern);
    return regex.IsMatch(path);
} 

var str = "aaa https://www.baidu.com/ bbb https://ask.csdn.net/questions/691988.html vvvv";
str=str.replace(/((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/g,"");
alert(str);

var str = "aaa c:/test/testa/12.txt vvvv";
str=str.replace(/[a-z]+:\/.+?\/(?=[^\/\\\'\"\s]+\.[a-z]+)/ig,"");
alert(str);

public File filePathPreProc(String pathstr){
pathstr=pathstr.replaceAll("////", "/").trim();
System.out.println(pathstr);
java.util.regex.Pattern p=java.util.regex.Pattern.compile("(^//.|^/|^[a-zA-Z])?:?/.+(/$)?");
java.util.regex.Matcher m=p.matcher(pathstr);
//不符合要求直接返回
if(!m.matches()){
return null;
}

public File filePathPreProc(String pathstr){
pathstr=pathstr.replaceAll("////", "/").trim();
System.out.println(pathstr);
java.util.regex.Pattern p=java.util.regex.Pattern.compile("(^//.|^/|^[a-zA-Z])?:?/.+(/$)?");
java.util.regex.Matcher m=p.matcher(pathstr);
//不符合要求直接返回
if(!m.matches()){
return null;
}
//这里开始文件名已经符合要求
File path=new File(pathstr);
//TODO:写自己的代码
return path;
}

这个函数是文件路径预处理函数,把用户输入的类似E://aaa//bbb ccc//cccc_ddd//alkf.xxx 或路径直接转为unix like文件路径格式,如果失败,返回空值(null)如果成功了,返回File对象。