From a80b1a2293481a74f37c791f2e9296531fc31fb5 Mon Sep 17 00:00:00 2001 From: Mars Ultor Date: Wed, 24 Dec 2025 20:04:14 -0600 Subject: [PATCH] moved to regex in parse time from line --- src/processing_utils.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/processing_utils.cpp b/src/processing_utils.cpp index 3022efb..f005ccd 100644 --- a/src/processing_utils.cpp +++ b/src/processing_utils.cpp @@ -31,17 +31,24 @@ bool parse_date_from_filename(std::string_view path, bool parse_time_from_line(std::string_view line, int& hour, int& min, int& sec) { - // Expect: [HH:MM:SS] - if (line.size() < 10 || line[0] != '[') + // Match [HH:MM:SS] anywhere in the line + static const std::regex re( + R"(\[(\d{2}):(\d{2}):(\d{2})\])", + std::regex::optimize + ); + + std::cmatch m; + if (!std::regex_search(line.begin(), line.end(), m, re)) return false; - hour = (line[1] - '0') * 10 + (line[2] - '0'); - min = (line[4] - '0') * 10 + (line[5] - '0'); - sec = (line[7] - '0') * 10 + (line[8] - '0'); + hour = (m[1].str()[0] - '0') * 10 + (m[1].str()[1] - '0'); + min = (m[2].str()[0] - '0') * 10 + (m[2].str()[1] - '0'); + sec = (m[3].str()[0] - '0') * 10 + (m[3].str()[1] - '0'); return true; } + #include #include