From 82bc109ecf808c935f2b7057e46f5d074ceaa7ac Mon Sep 17 00:00:00 2001 From: Benjamin Kraft Date: Mon, 12 Dec 2022 21:13:54 +0100 Subject: [PATCH] removes tags from test input --- src/main.cpp | 5 ++++- src/util.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3476398..b9d6a05 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,10 @@ Input getInput(int day, string key, bool useTestInput, int testFetchIndex) { string res = cpr::Get(cpr::Url{url}).text; size_t i1 = findAll(res, "")[testFetchIndex]; size_t i2 = findAll(res, "")[testFetchIndex]; - file << res.substr(i1 + 6, i2 - (i1 + 6)); + string codeContent = res.substr(i1 + 6, i2 - (i1 + 6)); + removeAll(codeContent, ""); + removeAll(codeContent, ""); + file << codeContent; file.close(); } } diff --git a/src/util.h b/src/util.h index c369cce..e329b32 100644 --- a/src/util.h +++ b/src/util.h @@ -30,4 +30,11 @@ inline vector findAll(const string& data, const string& toSearch){ } return indices; +} + +inline void removeAll(string& data, const string& toRemove) { + vector indices = findAll(data, toRemove); + std::sort(indices.rbegin(), indices.rend()); + for (size_t &i : indices) + data.erase(i, toRemove.size()); } \ No newline at end of file