2020-10-20

it2023-01-09  61

var fs=require(‘fs’); var logger = fs.createWriteStream(‘log.txt’, { flags:’a’}); fs.readFile(1.txt’,’utf-8, function(err,data){ if(err) { return } else { const arr=data.split(‘\n’); const test1=/^\d{4}.*/; arr.forEach(item=>{ if(test1.test(item)) { var date=item.match(/([1-2]{1}[0-9]{3}\.[0-9]{1,2}\.[0-9]{1,2}/); var money=item.match(/(\$[0-9]*\.[0-9]{2}/); logger.write(date[0]+:+money[0]+’\n’); } } } logger.end(); })
最新回复(0)