我有两个文件路径作为字符串:
const filePath = "reports/cucumber/7/cucumber/sample/json/login.json"
const reportFolder = "reports/cucumber/7/cucumber/sample"我需要比较这两种方法,然后得到如下输出
/json/login.json我该怎么做呢?
发布于 2021-10-06 07:06:06
您还可以使用String.replace()来获取差异:
const filePath = "reports/cucumber/7/cucumber/sample/json/login.json"
const reportFolder = "reports/cucumber/7/cucumber/sample"
const diff = filePath.replace(reportFolder, '');
console.log('Diff:', diff)
发布于 2021-10-06 07:00:03
const filePath = "reports/cucumber/7/cucumber/sample/json/login.json"
const reportFolder = "reports/cucumber/7/cucumber/sample"
const diff = (diffMe, diffBy) => diffMe.split(diffBy).join('')
const C = diff(filePath, reportFolder)
console.log(C)https://stackoverflow.com/questions/69461137
复制相似问题