mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Cleanup
This commit is contained in:
parent
4966802f14
commit
047fef4f6e
|
|
@ -1,15 +1,12 @@
|
|||
#include "text-helpers.hpp"
|
||||
|
||||
#include <regex>
|
||||
#include <QRegularExpression>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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\\)");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user