From 400846dd5619cc430bdebb1d333cd9281ebb8fbf Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Tue, 11 Feb 2025 13:54:21 +0100 Subject: [PATCH] Switch regex option multiline on And use a begin-of-line anchor in the pattern, which makes it faster and more specific. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 5c5da1b..2aa1a7e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) { } sc::requester req; std::string text {req.get("https://gitlab.com/gitlab-org/gitlab-foss/-/raw/master/CHANGELOG.md")}; - std::regex pat {R"(##\s+(\d+\.\d+\.\d+)\s+\((\d+-\d+-\d+))"}; + std::regex pat {R"(^##\s+(\d+\.\d+\.\d+)\s+\((\d+-\d+-\d+))", std::regex::multiline}; std::sregex_iterator beg {text.begin(), text.end(), pat}; std::sregex_iterator end {}; for (std::sregex_iterator i = beg; i != end; ++i) {