如何找到文件中单词之间或“startString”和“endString”行之间的所有行?
const fs = require('fs')
const startString = '-----CompilerOutput:-stderr----------'
const endString = '-----EndCompilerOutput---------------'
const file = fs.readFileSync('./history.log', 'utf8')
let arr = file.split(/\r?\n/);
arr.forEach((line, idx)=> {
if(line.includes(startString, endString)){
console.log((idx+1)+':'+ line);
}
})
绝地无双
相关分类