diff --git a/src/alternativesmodel.cpp b/src/alternativesmodel.cpp --- a/src/alternativesmodel.cpp +++ b/src/alternativesmodel.cpp @@ -63,7 +63,10 @@ } return false; } else if(constraint.contains(QLatin1Char('*'))) { - return QRegExp(constraint, Qt::CaseInsensitive, QRegExp::Wildcard).exactMatch(value.toString()); + const QRegularExpression re( + QRegularExpression::anchoredPattern(QRegularExpression::wildcardToRegularExpression(constraint)), + QRegularExpression::CaseInsensitiveOption); + return re.match(value.toString()).hasMatch(); } else { QMimeDatabase db; QMimeType mime = db.mimeTypeForName(value.toString()); diff --git a/src/plugins/phabricator/phabricatorjobs.cpp b/src/plugins/phabricator/phabricatorjobs.cpp --- a/src/plugins/phabricator/phabricatorjobs.cpp +++ b/src/plugins/phabricator/phabricatorjobs.cpp @@ -22,12 +22,13 @@ #include "debug.h" #include +#include #include #include // // // // // // // #include -#define COLOURCODES "\u001B[[0-9]*m" +const char s_colourCodes[] = "\u001B[[0-9]*m"; using namespace Phabricator; @@ -93,25 +94,25 @@ void DifferentialRevision::setErrorString(const QString& msg) { - QRegExp unwanted(QString::fromUtf8(COLOURCODES)); + QRegularExpression unwanted(QString::fromUtf8(s_colourCodes)); m_errorString = msg; m_errorString.replace(unwanted, QString()); } QString DifferentialRevision::scrubbedResult() { QString result = QString::fromUtf8(m_arcCmd.readAllStandardOutput()); // the return string can contain terminal text colour codes: remove them. - QRegExp unwanted(QString::fromUtf8(COLOURCODES)); + QRegularExpression unwanted(QString::fromUtf8(s_colourCodes)); result.replace(unwanted, QString()); return result; } QStringList DifferentialRevision::scrubbedResultList() { QStringList result = QString::fromUtf8(m_arcCmd.readAllStandardOutput()).split(QChar::LineFeed); // the return string can contain terminal text colour codes: remove them. - QRegExp unwanted(QString::fromUtf8(COLOURCODES)); + QRegularExpression unwanted(QString::fromUtf8(s_colourCodes)); result.replaceInStrings(unwanted, QString()); // remove all (now) empty strings result.removeAll(QString()); @@ -234,8 +235,8 @@ setPercent(99); const QStringList reviews = scrubbedResultList(); qCDebug(PLUGIN_PHABRICATOR) << "arc list returned:" << reviews; + const QRegularExpression revIDExpr(QStringLiteral(" D[0-9][0-9]*: ")); for (auto rev : reviews) { - QRegExp revIDExpr(QString::fromUtf8(" D[0-9][0-9]*: ")); int idStart = rev.indexOf(revIDExpr); if (idStart >= 0) { QString revID = rev.mid(idStart+1).split(QString::fromUtf8(": ")).at(0); diff --git a/src/plugins/reviewboard/quick/reviewboardrc.cpp b/src/plugins/reviewboard/quick/reviewboardrc.cpp --- a/src/plugins/reviewboard/quick/reviewboardrc.cpp +++ b/src/plugins/reviewboard/quick/reviewboardrc.cpp @@ -18,7 +18,7 @@ */ #include "reviewboardrc.h" -#include +#include #include #include #include @@ -36,18 +36,19 @@ //The .reviewboardrc files are python files, we'll read and if it doesn't work //Well bad luck. See: http://www.reviewboard.org/docs/rbtools/dev/rbt/configuration/ - QRegExp rx(QStringLiteral("([\\w_]+) *= *[\"'](.*)[\"']")); QFile f(filePath.toLocalFile()); if(!f.open(QFile::ReadOnly | QFile::Text)) { qWarning() << "couldn't open" << filePath; return; } + const QRegularExpression rx(QRegularExpression::anchoredPattern(QStringLiteral("([\\w]+) *= *[\"'](.*)[\"']"))); QHash values; QTextStream stream(&f); for(; !stream.atEnd(); ) { - if(rx.exactMatch(stream.readLine())) { - values.insert(rx.cap(1), rx.cap(2)); + QRegularExpressionMatch match = rx.match(stream.readLine()); + if(match.hasMatch()) { + values.insert(match.captured(1), match.captured(2)); } }