From 3b0d62f5c54bd6e2da7797a981daf898624d26ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82?= Date: Sun, 4 Jul 2021 13:02:12 +0200 Subject: [PATCH] Replace QRegExp with QRegularExpression (#2945) --- src/common/Args.cpp | 10 +++++----- src/util/NuulsUploader.cpp | 13 ++++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/common/Args.cpp b/src/common/Args.cpp index 10c2e9b96..f43ad6c21 100644 --- a/src/common/Args.cpp +++ b/src/common/Args.cpp @@ -133,11 +133,11 @@ void Args::applyCustomChannelLayout(const QString &argValue) QString platform = "t"; QString channelName = channelArg; - const QRegExp regExp("(.):(.*)"); - if (regExp.indexIn(channelArg) != -1) + const QRegularExpression regExp("(.):(.*)"); + if (auto match = regExp.match(channelArg); match.hasMatch()) { - platform = regExp.cap(1); - channelName = regExp.cap(2); + platform = match.captured(1); + channelName = match.captured(2); } // Twitch (default) @@ -147,7 +147,7 @@ void Args::applyCustomChannelLayout(const QString &argValue) // Set first tab as selected tab.selected_ = window.tabs_.empty(); - tab.rootNode_ = SplitNodeDescriptor{"twitch", channelName}; + tab.rootNode_ = SplitNodeDescriptor{{"twitch", channelName}}; window.tabs_.emplace_back(std::move(tab)); } diff --git a/src/util/NuulsUploader.cpp b/src/util/NuulsUploader.cpp index 0705861d0..606b38f14 100644 --- a/src/util/NuulsUploader.cpp +++ b/src/util/NuulsUploader.cpp @@ -105,12 +105,15 @@ QString getJSONValue(QJsonValue responseJson, QString jsonPattern) QString getLinkFromResponse(NetworkResult response, QString pattern) { - QRegExp regExp("\\{(.+)\\}"); - regExp.setMinimal(true); - while (regExp.indexIn(pattern) != -1) + QRegularExpression regExp("{(.+)}", + QRegularExpression::InvertedGreedinessOption); + auto match = regExp.match(pattern); + + while (match.hasMatch()) { - pattern.replace(regExp.cap(0), - getJSONValue(response.parseJson(), regExp.cap(1))); + pattern.replace(match.captured(0), + getJSONValue(response.parseJson(), match.captured(1))); + match = regExp.match(pattern); } return pattern; }