// 剔除与后缀_signature同名的文件
var arr = [
"/repository/temp/upload/idCard-0.jpg",
"/repository/temp/upload/idCard-1.jpg",
"/repository/temp/upload/idCard_IDcheck.jpg",
"/repository/temp/upload/222.pdf",
"/repository/temp/upload/Customer Declaration for VTM A.pdf",
"/repository/temp/upload/Customer Declaration for VTM.pdf",
"/repository/temp/upload/Customer Declaration for VTM_signature.pdf",
"/repository/temp/upload/HFE.pdf",
"/repository/temp/upload/HFESupplementInformation.pdf",
"/repository/temp/upload/HFESupplementInformation_signature.pdf",
"/repository/temp/upload/HFE_signature.pdf"
];
var arr2 = [], arr3 = [], arr4=[];
arr2 = arr.filter(function(item){
return item.lastIndexOf('_signature.pdf') != -1;
});
console.log(arr);
console.log(arr2);
arr3 = arr2.map(function(item){
return item.split('_signature.pdf')[0]+'.pdf';
});
console.log(arr3);
arr4 = arr.filter(function(item){
return arr3.indexOf(item) == -1;
});
console.log(arr4);
从一组文件名中保留某些同名且带后缀的文件
最新推荐文章于 2021-11-03 09:25:36 发布