Skip to content

Instantly share code, notes, and snippets.

@mariomka
Last active July 22, 2017 15:26
Show Gist options
  • Save mariomka/aff7f77c5e9d1a471d407933fe1a98bb to your computer and use it in GitHub Desktop.
Save mariomka/aff7f77c5e9d1a471d407933fe1a98bb to your computer and use it in GitHub Desktop.
Madrid Devs regex challenge. Node version.
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