如何显示所有结果而不以第一场比赛结束?此代码帮助我获取开始词和结束词之间的文本。但搜索在找到第一对后就结束了。您如何找到所有匹配项?
const file = fs.readFileSync('./history.txt', 'utf8')
const startString = '-----CompilerOutput:-stderr----------'
const endString = '-----EndCompilerOutput---------------'
const startIndex = file.indexOf(startString) + startString.length
const endIndex = file.indexOf(endString)
const between = file.slice(startIndex, endIndex)
console.log(between)
函数式编程
相关分类