Skip to content

Instantly share code, notes, and snippets.

@likev
Created September 12, 2017 06:15
Show Gist options
  • Save likev/466392052f741b561c5f8113a56fd8e7 to your computer and use it in GitHub Desktop.
Save likev/466392052f741b561c5f8113a56fd8e7 to your computer and use it in GitHub Desktop.
extract info line by line with Node.js (usage: node extract.js <ln.txt > result-ln.txt)
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const processLine = (line)=>{
var is_wu = false, is_mai=false;
if(line.search(/[^轻]雾/) !== -1){
is_wu = true;
//console.log(line);
//break;
}
if(line.search(/霾/) !== -1){
is_mai = true;
//console.log(line);
//break;
}
if(is_wu || is_mai){
console.log(is_wu+' '+is_mai+' '+ (is_wu&&is_mai) +' '+line);
}
}
rl.on('line', (input) => {
processLine(input);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment