From 37c866054adcf00e63ee2d3f2cf63a847350bfa6 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Wed, 27 Mar 2024 17:07:30 +0100 Subject: [PATCH] Fix regex for key-value-pair First group was a greedy match for the key, followed by a greedy match for the whitespace up to the '='. This caused the white space to become a suffix of the key... Solved by making it a non-greedy match. --- src/string_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string_utils.cpp b/src/string_utils.cpp index e10a49b..4326923 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -93,7 +93,7 @@ map sc::parse_ini_file(const string& path, bool ignore_sections) prefix = string{m[1]} + '.'; } } - regex key_value_pat {R"(^\s*(.*)\s*=\s*("?)(.*)\2)"}; + regex key_value_pat {R"(^\s*(.*?)\s*=\s*("?)(.*)\2)"}; smatch match; if (regex_search(line, match, key_value_pat)) { result[prefix + string{match[1]}] = match[3];