Last active
July 22, 2017 15:26
-
-
Save mariomka/aff7f77c5e9d1a471d407933fe1a98bb to your computer and use it in GitHub Desktop.
Madrid Devs regex challenge. Node version.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const readline = require('readline') | |
const fs = require('fs') | |
const rl = readline.createInterface({ | |
input: fs.createReadStream('muestra_log.txt') | |
}) | |
const pattern = /(.*?) (.*?) (.*?) \[(.*?)\] "(.*?) (.*?) (.*?)" (\d+?|-) (\d+?|-) "(.*?)" (.*?) "(.*?)" "(.*?)" ([\d\.]+?|-) "(\d*?|-)" "(.*?)"/ | |
let count = 0 | |
rl.on('line', function (line) { | |
let matches = pattern.exec(line) | |
if (matches) { | |
// Do something | |
} | |
count++ | |
}) | |
rl.on('close', function (line) { | |
console.log(`Processed ${count} lines`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment