From 34b089b19aa4a0ac35a0cf751aba0b62a197b3c3 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Wed, 20 Jul 2022 14:05:00 -0400 Subject: [PATCH] Got the two starters down. --- 02-filter-a-log-file/step1.js | 5 ++++- 02-filter-a-log-file/step2.js | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 02-filter-a-log-file/step2.js diff --git a/02-filter-a-log-file/step1.js b/02-filter-a-log-file/step1.js index 9f1c1bf..e3994bb 100644 --- a/02-filter-a-log-file/step1.js +++ b/02-filter-a-log-file/step1.js @@ -4,4 +4,7 @@ const raw_log = fs.readFileSync(process.argv[2]); const lines = raw_log.toString().split("\n"); -console.log(lines); +const search = new RegExp(process.argv[3]); + +// continue here, how do you find all the lines matching the regex? +// how complex can you make this? Is it necessary? diff --git a/02-filter-a-log-file/step2.js b/02-filter-a-log-file/step2.js new file mode 100644 index 0000000..3cdc1e0 --- /dev/null +++ b/02-filter-a-log-file/step2.js @@ -0,0 +1,8 @@ +import fs from "fs"; + +const raw_log = fs.readFileSync(process.argv[2]); + +const lines = raw_log.toString().split("\n"); + +// now you have to figure out how to split each line of the +// web log into something meaningful