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();
})
转载请注明原文地址: https://lol.8miu.com/read-608.html