From 047fef4f6e73578a61e943eed8185cb2a4f4fc81 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Sat, 7 Mar 2026 21:15:37 +0100 Subject: [PATCH] Cleanup --- plugins/base/utils/text-helpers.cpp | 9 +++------ tests/test-regex.cpp | 8 -------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/plugins/base/utils/text-helpers.cpp b/plugins/base/utils/text-helpers.cpp index 8ab9450f..024826e4 100644 --- a/plugins/base/utils/text-helpers.cpp +++ b/plugins/base/utils/text-helpers.cpp @@ -1,15 +1,12 @@ #include "text-helpers.hpp" -#include +#include namespace advss { -QString EscapeForRegex(const QString &s) +QString EscapeForRegex(const QString &input) { - static std::regex specialChars{R"([-[\]{}()*+?.,\^$|#\s])"}; - std::string input = s.toStdString(); - return QString::fromStdString( - std::regex_replace(input, specialChars, R"(\$&)")); + return QRegularExpression::escape(input); } } // namespace advss diff --git a/tests/test-regex.cpp b/tests/test-regex.cpp index 52ac4a61..becc3b22 100644 --- a/tests/test-regex.cpp +++ b/tests/test-regex.cpp @@ -80,11 +80,3 @@ TEST_CASE("Matches (PartialMatchRegexConfig)", "[regex-config]") result = regex.Matches(std::string("abc"), "a"); REQUIRE(result == true); } - -TEST_CASE("EscapeForRegex , [text-helpers]") -{ - REQUIRE(advss::EscapeForRegex("") == ""); - REQUIRE(advss::EscapeForRegex("abcdefg") == "abcdefg"); - REQUIRE(advss::EscapeForRegex("(abcdefg)") == "\\(abcdefg\\)"); - REQUIRE(advss::EscapeForRegex("\\(abcdefg)") == "\\\\(abcdefg\\)"); -}