[office/kmymoney] /: Replace remaining QRegExp with QRegularExpression

Thomas Baumgart null at kde.org
Wed Feb 23 15:48:54 GMT 2022


Git commit 3edad8ce7189980167309582cfa7d77af447ac57 by Thomas Baumgart.
Committed on 23/02/2022 at 15:48.
Pushed by tbaumgart into branch 'master'.

Replace remaining QRegExp with QRegularExpression

M  +6    -6    doc/details-investments.docbook
M  +4    -4    doc/details-search.docbook
M  +8    -7    kmymoney/converter/mymoneystatementreader.cpp
M  +23   -21   kmymoney/dialogs/kequitypriceupdatedlg.cpp
M  +8    -9    kmymoney/mymoney/mymoneyaccount.cpp
M  +13   -10   kmymoney/mymoney/mymoneyaccountloan.cpp
M  +6    -3    kmymoney/mymoney/mymoneycostcenter.cpp
M  +11   -10   kmymoney/mymoney/mymoneyfile.cpp
M  +4    -3    kmymoney/mymoney/mymoneypayee.cpp
M  +15   -6    kmymoney/mymoney/mymoneytracer.cpp
M  +2    -2    kmymoney/mymoney/mymoneyutils.cpp
M  +20   -0    kmymoney/mymoney/tests/mymoneyutils-test.cpp
M  +2    -0    kmymoney/mymoney/tests/mymoneyutils-test.h
M  +4    -3    kmymoney/plugins/csv/import/csvwizard.cpp
M  +3    -2    kmymoney/plugins/gnc/import/gncimporter.cpp
M  +21   -16   kmymoney/plugins/kbanking/kbanking.cpp
M  +5    -4    kmymoney/plugins/kbanking/widgets/chiptandialog.cpp
M  +2    -2    kmymoney/plugins/kbanking/widgets/phototandialog.cpp
M  +7    -6    kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp
M  +12   -11   kmymoney/plugins/ofx/import/dialogs/mymoneyofxconnector.cpp
M  +18   -17   kmymoney/plugins/ofx/import/ofxpartner.cpp
M  +14   -10   kmymoney/plugins/qif/config/mymoneyqifprofile.cpp
M  +21   -20   kmymoney/plugins/qif/import/mymoneyqifreader.cpp
M  +1    -1    kmymoney/plugins/sql/mymoneydbdef.cpp
M  +1    -1    kmymoney/plugins/sql/mymoneystoragesql_p.h
M  +27   -24   kmymoney/plugins/views/reports/core/pivottable.cpp
M  +3    -4    kmymoney/plugins/views/reports/core/tests/pivottable-test.cpp
M  +10   -6    kmymoney/plugins/xml/kcm_xmlstorage.cpp
M  +10   -7    kmymoney/plugins/xml/ksettingsgpg.cpp
M  +1    -1    kmymoney/plugins/xml/mymoneystorageanon.cpp
M  +7    -5    kmymoney/plugins/xml/xmlstorage.cpp
M  +4    -3    kmymoney/settings/kmymoneysettings_addons.cpp
M  +9    -7    kmymoney/tests/testutilities.cpp
M  +0    -1    kmymoney/views/kmymoneyview.cpp
M  +6    -4    kmymoney/views/kpayeesview_p.h
M  +3    -3    kmymoney/views/ledgerview.cpp
M  +8    -6    kmymoney/widgets/kaccounttemplateselector.cpp
M  +9    -8    kmymoney/widgets/kmymoneyaccountcombo.cpp
M  +4    -5    kmymoney/widgets/kmymoneyaccountcompletion.cpp
M  +11   -9    kmymoney/widgets/kmymoneyaccountselector.cpp
M  +1    -1    kmymoney/widgets/kmymoneyaccountselector.h
M  +5    -5    kmymoney/widgets/kmymoneycalculator.cpp
M  +2    -2    kmymoney/widgets/kmymoneycompletion_p.h
M  +14   -15   kmymoney/widgets/kmymoneyselector.cpp
M  +13   -13   kmymoney/widgets/kmymoneyselector.h
M  +4    -3    tools/xea2kmt.cpp

https://invent.kde.org/office/kmymoney/commit/3edad8ce7189980167309582cfa7d77af447ac57

diff --git a/doc/details-investments.docbook b/doc/details-investments.docbook
index f7cc0a928..0eab3fd2f 100644
--- a/doc/details-investments.docbook
+++ b/doc/details-investments.docbook
@@ -172,7 +172,7 @@
     rounding errors which can make &kmymoney; unable to exactly match the information
     shown by your brokerage institution.
   </para></listitem>
-  
+
   <listitem><para> Trading market.  Where the stock trades.  This is an optional
     field which is provided for your convenience.  This information is not used
     anywhere else within &kmymoney;.
@@ -248,7 +248,7 @@
     possible.
   </para>
 </note>
-      
+
 <para>
   It is possible to own shares of the same security in different investment accounts,
   such as a regular investment account and also a retirement account.  If you follow the
@@ -287,7 +287,7 @@
   online source.  In addition, it is possible to close an empty account, or to
   reopen a closed account.  The order for value, quantity and price can be changed
   on the screen by selecting any of them by left clicking on the item in the top bar and
-  dragging it to the left or right. 
+  dragging it to the left or right.
 </para>
 <para>
   If you choose to Edit an Investment, you will use the <guilabel>Investment detail
@@ -551,7 +551,7 @@
 <title>Online Price Quotes</title>
 <para>
   &kmymoney; has the ability to download the latest prices for your securities
-  and currencies via the web.  
+  and currencies via the web.
 </para>
 
 <sect3>
@@ -587,7 +587,7 @@
   Source</quote>.  This is the name of the service from which the quote should
   be fetched.  &kmymoney; ships with several sources to choose from.  Yahoo is the
   recommended default source, and should work for most investments and all
-  currencies. 
+  currencies.
 </para>
 
 <para>
@@ -704,7 +704,7 @@
 <para>
   The page parser looks for a symbol, a date, and a price.  Regular expressions tell
   it how to extract those items from the page.  Please review the documentation for
-  the <ulink url="https://doc.qt.io/qt-5/qregexp.html">QRegExp
+  the <ulink url="https://doc.qt.io/qt-5/qregularexpression.html">QRegularExpression
   class</ulink> for the exact syntax regular expressions used by &kmymoney;.  There
   should be exactly one capture expression, surrounded by parentheses, in each regexp
   field.  The date format further tells the date parser the order of year, month, and
diff --git a/doc/details-search.docbook b/doc/details-search.docbook
index 4ebbaef71..9bae35dc8 100644
--- a/doc/details-search.docbook
+++ b/doc/details-search.docbook
@@ -115,7 +115,7 @@
   If you check the <guilabel>Treat Text as regular expression</guilabel> box,
   the text will be treated as a regular expression.  For details on how to
   craft a regular expression, visit the &Qt; documentation about the
-  <ulink url="https://doc.qt.io/qt-5/qregexp.html">QRegExp
+  <ulink url="https://doc.qt.io/qt-5/qregularexpression.html">QRegularExpression
   class</ulink>.
 </para>
 </sect2>
@@ -135,7 +135,7 @@
 </screenshot>
 
 <para>
-  This tab allows you to specify the accounts that should be searched. 
+  This tab allows you to specify the accounts that should be searched.
 </para>
 
 <para>
@@ -218,7 +218,7 @@
 </screenshot>
 
 <para>
-  This tab allows you to specify which categories should be searched. 
+  This tab allows you to specify which categories should be searched.
 </para>
 
 <para>
@@ -254,7 +254,7 @@
 </screenshot>
 
 <para>
-  This tab allows you to specify which payees should be searched. 
+  This tab allows you to specify which payees should be searched.
 </para>
 
 <para>
diff --git a/kmymoney/converter/mymoneystatementreader.cpp b/kmymoney/converter/mymoneystatementreader.cpp
index c86ff4557..8dbf3242e 100644
--- a/kmymoney/converter/mymoneystatementreader.cpp
+++ b/kmymoney/converter/mymoneystatementreader.cpp
@@ -946,19 +946,20 @@ void MyMoneyStatementReader::processTransactionEntry(const MyMoneyStatement::Tra
 
                 case eMyMoney::Payee::MatchType::Name:
                 case eMyMoney::Payee::MatchType::NameExact:
-                    keys << QString("%1").arg(QRegExp::escape((*it_p).name()));
+                    keys << QString("%1").arg(QRegularExpression::escape((*it_p).name()));
                     if(matchType == eMyMoney::Payee::MatchType::NameExact) {
                         keys.clear();
-                        keys << QString("^%1$").arg(QRegExp::escape((*it_p).name()));
+                        keys << QString("^%1$").arg(QRegularExpression::escape((*it_p).name()));
                     }
                 // intentional fall through
 
                 case eMyMoney::Payee::MatchType::Key:
                     for (it_s = keys.constBegin(); it_s != keys.constEnd(); ++it_s) {
-                        QRegExp exp(*it_s, ignoreCase ? Qt::CaseInsensitive : Qt::CaseSensitive);
-                        if (exp.indexIn(payeename) != -1) {
-                            qDebug("Found match with '%s' on '%s'", qPrintable(payeename), qPrintable((*it_p).name()));
-                            matchMap[exp.matchedLength()] = (*it_p).id();
+                        QRegularExpression exp(*it_s, ignoreCase ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption);
+                        QRegularExpressionMatch match(exp.match(payeename));
+                        if (match.hasMatch()) {
+                            qDebug() << "Found match with" << payeename << "on" << (*it_p).name() << "for" << match.capturedLength();
+                            matchMap[match.capturedLength()] = (*it_p).id();
                         }
                     }
                     break;
@@ -1020,7 +1021,7 @@ void MyMoneyStatementReader::processTransactionEntry(const MyMoneyStatement::Tra
                 // is called in the context of an automatic procedure it
                 // might distract the user.
                 payee.setName(payeename);
-                payee.setMatchData(eMyMoney::Payee::MatchType::Key, true, QStringList() << QString("^%1$").arg(QRegExp::escape(payeename)));
+                payee.setMatchData(eMyMoney::Payee::MatchType::Key, true, QStringList() << QString("^%1$").arg(QRegularExpression::escape(payeename)));
                 if (m_askPayeeCategory) {
                     // We use a QPointer because the dialog may get deleted
                     // during exec() if the parent of the dialog gets deleted.
diff --git a/kmymoney/dialogs/kequitypriceupdatedlg.cpp b/kmymoney/dialogs/kequitypriceupdatedlg.cpp
index 2f8a62c63..19294b9d7 100644
--- a/kmymoney/dialogs/kequitypriceupdatedlg.cpp
+++ b/kmymoney/dialogs/kequitypriceupdatedlg.cpp
@@ -58,11 +58,12 @@ class KEquityPriceUpdateDlgPrivate
     Q_DECLARE_PUBLIC(KEquityPriceUpdateDlg)
 
 public:
-    explicit KEquityPriceUpdateDlgPrivate(KEquityPriceUpdateDlg *qq) :
-        q_ptr(qq),
-        ui(new Ui::KEquityPriceUpdateDlg),
-        m_fUpdateAll(false),
-        m_updatingPricePolicy(eDialogs::UpdatePrice::All)
+    explicit KEquityPriceUpdateDlgPrivate(KEquityPriceUpdateDlg* qq)
+        : q_ptr(qq)
+        , ui(new Ui::KEquityPriceUpdateDlg)
+        , m_fUpdateAll(false)
+        , m_updatingPricePolicy(eDialogs::UpdatePrice::All)
+        , m_splitRegex("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", QRegularExpression::CaseInsensitiveOption)
     {
     }
 
@@ -109,10 +110,10 @@ public:
 
         // send in securityId == "XXX YYY" to get a single-shot update for XXX to YYY.
         // for consistency reasons, this accepts the same delimiters as WebPriceQuote::launch()
-        QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive);
+        QRegularExpressionMatch match(m_splitRegex.match(securityId));
         MyMoneySecurityPair currencyIds;
-        if (splitrx.indexIn(securityId) != -1) {
-            currencyIds = MyMoneySecurityPair(splitrx.cap(1), splitrx.cap(2));
+        if (match.hasMatch()) {
+            currencyIds = MyMoneySecurityPair(match.captured(1), match.captured(2));
         }
 
         MyMoneyPriceList prices = file->priceList();
@@ -319,11 +320,12 @@ public:
         }
     }
 
-    KEquityPriceUpdateDlg      *q_ptr;
-    Ui::KEquityPriceUpdateDlg  *ui;
-    bool                        m_fUpdateAll;
-    eDialogs::UpdatePrice        m_updatingPricePolicy;
-    WebPriceQuote               m_webQuote;
+    KEquityPriceUpdateDlg* q_ptr;
+    Ui::KEquityPriceUpdateDlg* ui;
+    bool m_fUpdateAll;
+    eDialogs::UpdatePrice m_updatingPricePolicy;
+    WebPriceQuote m_webQuote;
+    QRegularExpression m_splitRegex;
 };
 
 KEquityPriceUpdateDlg::KEquityPriceUpdateDlg(QWidget *parent, const QString& securityId) :
@@ -607,11 +609,11 @@ void KEquityPriceUpdateDlg::slotReceivedCSVQuote(const QString& _kmmID, const QS
             }
 
         } else {
-            QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive);
-            if (splitrx.indexIn(_kmmID) != -1) {
+            QRegularExpressionMatch match(d->m_splitRegex.match(_kmmID));
+            if (match.hasMatch()) {
                 try {
-                    fromCurrency = MyMoneyFile::instance()->security(splitrx.cap(2).toUtf8());
-                    toCurrency = MyMoneyFile::instance()->security(splitrx.cap(1).toUtf8());
+                    fromCurrency = MyMoneyFile::instance()->security(match.captured(2).toUtf8());
+                    toCurrency = MyMoneyFile::instance()->security(match.captured(1).toUtf8());
                 } catch (const MyMoneyException &) {
                     fromCurrency = toCurrency = MyMoneySecurity();
                 }
@@ -755,11 +757,11 @@ void KEquityPriceUpdateDlg::slotReceivedQuote(const QString& _kmmID, const QStri
                 }
 
             } else {
-                QRegExp splitrx("([0-9a-z\\.]+)[^a-z0-9]+([0-9a-z\\.]+)", Qt::CaseInsensitive);
-                if (splitrx.indexIn(_kmmID) != -1) {
+                QRegularExpressionMatch match(d->m_splitRegex.match(_kmmID));
+                if (match.hasMatch()) {
                     try {
-                        fromCurrency = MyMoneyFile::instance()->security(splitrx.cap(2).toUtf8());
-                        toCurrency = MyMoneyFile::instance()->security(splitrx.cap(1).toUtf8());
+                        fromCurrency = MyMoneyFile::instance()->security(match.captured(2).toUtf8());
+                        toCurrency = MyMoneyFile::instance()->security(match.captured(1).toUtf8());
                     } catch (const MyMoneyException &) {
                         fromCurrency = toCurrency = MyMoneySecurity();
                     }
diff --git a/kmymoney/mymoney/mymoneyaccount.cpp b/kmymoney/mymoney/mymoneyaccount.cpp
index cbdf8d6e4..445a27d74 100644
--- a/kmymoney/mymoney/mymoneyaccount.cpp
+++ b/kmymoney/mymoney/mymoneyaccount.cpp
@@ -14,13 +14,12 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QRegExp>
+#include <QDebug>
+#include <QIcon>
+#include <QPainter>
 #include <QPixmap>
 #include <QPixmapCache>
-#include <QPainter>
-#include <QIcon>
 #include <QSet>
-#include <QDebug>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -30,17 +29,17 @@
 // ----------------------------------------------------------------------------
 // Project Includes
 
-#include "mymoneyutils.h"
+#include "icons.h"
 #include "mymoneyexception.h"
-#include "mymoneysplit.h"
 #include "mymoneyfile.h"
-#include "mymoneysecurity.h"
 #include "mymoneyinstitution.h"
 #include "mymoneypayee.h"
-#include "payeeidentifier/payeeidentifiertyped.h"
+#include "mymoneysecurity.h"
+#include "mymoneysplit.h"
+#include "mymoneyutils.h"
 #include "payeeidentifier/ibanbic/ibanbic.h"
 #include "payeeidentifier/nationalaccount/nationalaccount.h"
-#include "icons/icons.h"
+#include "payeeidentifier/payeeidentifiertyped.h"
 
 using namespace Icons;
 
diff --git a/kmymoney/mymoney/mymoneyaccountloan.cpp b/kmymoney/mymoney/mymoneyaccountloan.cpp
index 903c1de43..29d33531d 100644
--- a/kmymoney/mymoney/mymoneyaccountloan.cpp
+++ b/kmymoney/mymoney/mymoneyaccountloan.cpp
@@ -13,9 +13,9 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QRegExp>
 #include <QDate>
 #include <QMap>
+#include <QRegularExpression>
 #include <QSet>
 
 // ----------------------------------------------------------------------------
@@ -52,11 +52,12 @@ const MyMoneyMoney MyMoneyAccountLoan::interestRate(const QDate& date) const
 
     key.sprintf("ir-%04d-%02d-%02d", date.year(), date.month(), date.day());
 
-    QRegExp regExp("ir-(\\d{4})-(\\d{2})-(\\d{2})");
+    const QRegularExpression interestRateExp("ir-(\\d{4})-(\\d{2})-(\\d{2})");
 
     QMap<QString, QString>::ConstIterator it;
     for (it = pairs().constBegin(); it != pairs().constEnd(); ++it) {
-        if (regExp.indexIn(it.key()) > -1) {
+        const auto interestRateDate(interestRateExp.match(it.key()));
+        if (interestRateDate.hasMatch()) {
             if (qstrcmp(it.key().toLatin1(), key.toLatin1()) <= 0)
                 val = *it;
             else
@@ -102,9 +103,10 @@ const QDate MyMoneyAccountLoan::nextInterestChange() const
 {
     QDate rc;
 
-    QRegExp regExp("(\\d{4})-(\\d{2})-(\\d{2})");
-    if (regExp.indexIn(value("interest-nextchange")) != -1) {
-        rc.setDate(regExp.cap(1).toInt(), regExp.cap(2).toInt(), regExp.cap(3).toInt());
+    const QRegularExpression nextChangeExp("(\\d{4})-(\\d{2})-(\\d{2})");
+    const auto nextChange(nextChangeExp.match(value("interest-nextchange")));
+    if (nextChange.hasMatch()) {
+        rc.setDate(nextChange.captured(1).toInt(), nextChange.captured(2).toInt(), nextChange.captured(3).toInt());
     }
     return rc;
 }
@@ -121,11 +123,12 @@ int MyMoneyAccountLoan::interestChangeFrequency(int* unit) const
     if (unit)
         *unit = 1;
 
-    QRegExp regExp("(\\d+)/(\\d{1})");
-    if (regExp.indexIn(value("interest-changefrequency")) != -1) {
-        rc = regExp.cap(1).toInt();
+    const QRegularExpression frequencyExp("(\\d+)/(\\d{1})");
+    const auto frequency(frequencyExp.match(value("interest-changefrequency")));
+    if (frequency.hasMatch()) {
+        rc = frequency.captured(1).toInt();
         if (unit != 0) {
-            *unit = regExp.cap(2).toInt();
+            *unit = frequency.captured(2).toInt();
         }
     }
     return rc;
diff --git a/kmymoney/mymoney/mymoneycostcenter.cpp b/kmymoney/mymoney/mymoneycostcenter.cpp
index 2feef8732..eb00ba9de 100644
--- a/kmymoney/mymoney/mymoneycostcenter.cpp
+++ b/kmymoney/mymoney/mymoneycostcenter.cpp
@@ -9,6 +9,8 @@
 // QT Includes
 
 #include <QCollator>
+#include <QRegularExpression>
+#include <QRegularExpressionMatch>
 #include <QSet>
 
 // ----------------------------------------------------------------------------
@@ -91,9 +93,10 @@ void MyMoneyCostCenter::setName(const QString& val)
 QString MyMoneyCostCenter::shortName() const
 {
     Q_D(const MyMoneyCostCenter);
-    QRegExp shortNumberExp("^(\\d+)\\s.+");
-    if(shortNumberExp.exactMatch(d->m_name)) {
-        return shortNumberExp.cap(1);
+    const QRegularExpression shortNumberExp("^(\\d+)\\s.+");
+    const auto shortNumber(shortNumberExp.match(d->m_name));
+    if (shortNumber.hasMatch()) {
+        return shortNumber.captured(1);
     }
     return d->m_name;
 }
diff --git a/kmymoney/mymoney/mymoneyfile.cpp b/kmymoney/mymoney/mymoneyfile.cpp
index d6687d082..5c62475da 100644
--- a/kmymoney/mymoney/mymoneyfile.cpp
+++ b/kmymoney/mymoney/mymoneyfile.cpp
@@ -17,14 +17,15 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QString>
+#include <QAction>
+#include <QBitArray>
+#include <QDebug>
 #include <QList>
-#include <QUuid>
 #include <QLocale>
-#include <QBitArray>
-#include <QAction>
+#include <QRegularExpression>
+#include <QString>
 #include <QTimer>
-#include <QDebug>
+#include <QUuid>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -1491,11 +1492,11 @@ MyMoneyAccount MyMoneyFile::createOpeningBalanceAccount(const MyMoneySecurity& s
     // find present opening balance accounts without containing '('
     QString name;
     QString parentAccountId;
-    QRegExp exp(QString("\\([A-Z]{3}\\)"));
+    const QRegularExpression currencyExp(QLatin1String("\\([A-Z]{3}\\)"));
 
     for (it = accounts.constBegin(); it != accounts.constEnd(); ++it) {
-        if (it->value("OpeningBalanceAccount") == QLatin1String("Yes")
-                && exp.indexIn(it->name()) == -1) {
+        const auto currencyMatch(currencyExp.match(it->name()));
+        if (it->value("OpeningBalanceAccount") == QLatin1String("Yes") && currencyMatch.hasMatch()) {
             name = it->name();
             parentAccountId = it->parentAccountId();
             break;
@@ -3820,8 +3821,8 @@ QSet<QString> MyMoneyFile::referencedObjects() const
 bool MyMoneyFile::checkNoUsed(const QString& accId, const QString& no) const
 {
     // by definition, an empty string or a non-numeric string is not used
-    QRegExp exp(QString("(.*\\D)?(\\d+)(\\D.*)?"));
-    if (no.isEmpty() || exp.indexIn(no) == -1)
+    const QRegularExpression checkNumberExp(QLatin1String("(.*\\D)?(\\d+)(\\D.*)?"));
+    if (no.isEmpty() || !checkNumberExp.match(no).hasMatch())
         return false;
 
     const auto model = &d->journalModel;
diff --git a/kmymoney/mymoney/mymoneypayee.cpp b/kmymoney/mymoney/mymoneypayee.cpp
index 8ebb32449..feb9555e0 100644
--- a/kmymoney/mymoney/mymoneypayee.cpp
+++ b/kmymoney/mymoney/mymoneypayee.cpp
@@ -13,9 +13,10 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
+#include <QRegularExpression>
+#include <QSet>
 #include <QString>
 #include <QStringList>
-#include <QSet>
 
 // ----------------------------------------------------------------------------
 // Project Includes
@@ -264,8 +265,8 @@ void MyMoneyPayee::setMatchData(eMyMoney::Payee::MatchType type, bool ignorecase
     if (d->m_matchingEnabled) {
         d->m_usingMatchKey = (type == eMyMoney::Payee::MatchType::Key);
         if (d->m_usingMatchKey) {
-            QRegExp validKeyRegExp("[^ ]");
-            QStringList filteredKeys = keys.filter(validKeyRegExp);
+            const QRegularExpression validKeyRegExp(QLatin1String("[^ ]"));
+            const auto filteredKeys = keys.filter(validKeyRegExp);
             d->m_matchKey = filteredKeys.join(QLatin1Char('\n'));
         } else if(type == eMyMoney::Payee::MatchType::NameExact) {
             d->m_matchKey = QLatin1String("^$");
diff --git a/kmymoney/mymoney/mymoneytracer.cpp b/kmymoney/mymoney/mymoneytracer.cpp
index edbb03601..7589534c5 100644
--- a/kmymoney/mymoney/mymoneytracer.cpp
+++ b/kmymoney/mymoney/mymoneytracer.cpp
@@ -7,11 +7,19 @@
 #include "mymoneytracer.h"
 
 #include <iostream>
-
 #include <cstdio>
 #include <cstdarg>
 
-#include <QRegExp>
+// ----------------------------------------------------------------------------
+// QT Includes
+
+#include <QRegularExpression>
+
+// ----------------------------------------------------------------------------
+// KDE Includes
+
+// ----------------------------------------------------------------------------
+// Project Includes
 
 class MyMoneyTracerPrivate
 {
@@ -37,10 +45,11 @@ MyMoneyTracer::MyMoneyTracer(const char* name) :
 {
     Q_D(MyMoneyTracer);
     if (d->m_onoff) {
-        QRegExp exp("(.*)::(.*)");
-        if (exp.indexIn(name) != -1) {
-            d->m_className = exp.cap(1);
-            d->m_memberName = exp.cap(2);
+        const QRegularExpression classMethodExp("(.*)::(.*)");
+        const auto classAndMethod(classMethodExp.match(name));
+        if (classAndMethod.hasMatch()) {
+            d->m_className = classAndMethod.captured(1);
+            d->m_memberName = classAndMethod.captured(2);
         } else {
             d->m_className = QString(name);
             d->m_memberName.clear();
diff --git a/kmymoney/mymoney/mymoneyutils.cpp b/kmymoney/mymoney/mymoneyutils.cpp
index 84d3a42d4..e7a75a8fb 100644
--- a/kmymoney/mymoney/mymoneyutils.cpp
+++ b/kmymoney/mymoney/mymoneyutils.cpp
@@ -11,9 +11,9 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QRegExp>
 #include <QDate>
 #include <QLocale>
+#include <QRegularExpression>
 
 // ----------------------------------------------------------------------------
 // KDE Headers
@@ -97,7 +97,7 @@ unsigned long MyMoneyUtils::extractId(const QString& txt)
     int pos;
     unsigned long rc = 0;
 
-    pos = txt.indexOf(QRegExp("\\d+"), 0);
+    pos = txt.indexOf(QRegularExpression("\\d+"));
     if (pos != -1) {
         rc = txt.mid(pos).toInt();
     }
diff --git a/kmymoney/mymoney/tests/mymoneyutils-test.cpp b/kmymoney/mymoney/tests/mymoneyutils-test.cpp
index 3a3529c9e..45adb5204 100644
--- a/kmymoney/mymoney/tests/mymoneyutils-test.cpp
+++ b/kmymoney/mymoney/tests/mymoneyutils-test.cpp
@@ -72,3 +72,23 @@ void MyMoneyUtilsTest::testConvertRegularExpressionToWildcard()
 
     QCOMPARE(MyMoneyUtils::convertRegularExpressionToWildcard(regex), wildcard);
 }
+
+void MyMoneyUtilsTest::testExtractId_data()
+{
+    QTest::addColumn<QString>("string");
+    QTest::addColumn<unsigned long>("result");
+
+    QTest::newRow("empty") << QString() << 0UL;
+    QTest::newRow("no-number") << QStringLiteral("thb") << 0UL;
+    QTest::newRow("number-only") << QStringLiteral("123") << 123UL;
+    QTest::newRow("text-leadin") << QStringLiteral("TEST-123") << 123UL;
+    QTest::newRow("text-leadout") << QStringLiteral("123-TEST") << 0UL;
+}
+
+void MyMoneyUtilsTest::testExtractId()
+{
+    QFETCH(QString, string);
+    QFETCH(unsigned long, result);
+
+    QCOMPARE(MyMoneyUtils::extractId(string), result);
+}
diff --git a/kmymoney/mymoney/tests/mymoneyutils-test.h b/kmymoney/mymoney/tests/mymoneyutils-test.h
index 29ea637b3..c7fa9472b 100644
--- a/kmymoney/mymoney/tests/mymoneyutils-test.h
+++ b/kmymoney/mymoney/tests/mymoneyutils-test.h
@@ -20,6 +20,8 @@ private Q_SLOTS:
     void testConvertWildcardToRegularExpression();
     void testConvertRegularExpressionToWildcard_data();
     void testConvertRegularExpressionToWildcard();
+    void testExtractId_data();
+    void testExtractId();
 };
 
 #endif // MYMONEYUTILSTEST_H
diff --git a/kmymoney/plugins/csv/import/csvwizard.cpp b/kmymoney/plugins/csv/import/csvwizard.cpp
index 40fa630e0..3455ebcdd 100644
--- a/kmymoney/plugins/csv/import/csvwizard.cpp
+++ b/kmymoney/plugins/csv/import/csvwizard.cpp
@@ -704,7 +704,7 @@ void SeparatorPage::initializeEncodingCombobox()
 
     QList<QTextCodec *>   codecs;
     QMap<QString, QTextCodec *> codecMap;
-    QRegExp iso8859RegExp(QStringLiteral("ISO[- ]8859-([0-9]+).*"));
+    const QRegularExpression iso8859RegExp(QLatin1String("ISO[- ]8859-([0-9]+).*"));
 
     foreach (const auto mib, QTextCodec::availableMibs()) {
         QTextCodec *codec = QTextCodec::codecForMib(mib);
@@ -712,12 +712,13 @@ void SeparatorPage::initializeEncodingCombobox()
         QString sortKey = codec->name().toUpper();
         int rank;
 
+        const auto iso8859(iso8859RegExp.match(sortKey));
         if (sortKey.startsWith(QLatin1String("UTF-8"))) {             // krazy:exclude=strings
             rank = 1;
         } else if (sortKey.startsWith(QLatin1String("UTF-16"))) {            // krazy:exclude=strings
             rank = 2;
-        } else if (iso8859RegExp.exactMatch(sortKey)) {
-            if (iso8859RegExp.cap(1).size() == 1)
+        } else if (iso8859.hasMatch()) {
+            if (iso8859.captured(1).size() == 1)
                 rank = 3;
             else
                 rank = 4;
diff --git a/kmymoney/plugins/gnc/import/gncimporter.cpp b/kmymoney/plugins/gnc/import/gncimporter.cpp
index 3a5caf177..822848517 100644
--- a/kmymoney/plugins/gnc/import/gncimporter.cpp
+++ b/kmymoney/plugins/gnc/import/gncimporter.cpp
@@ -11,6 +11,7 @@
 // QT Includes
 
 #include <QFileDialog>
+#include <QRegularExpression>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -94,8 +95,8 @@ bool GNCImporter::open(const QUrl &url)
 
     QString txt(qbaFileHeader);
 
-    QRegExp gncexp("<gnc-v(\\d+)");
-    if (!(gncexp.indexIn(txt) != -1)) {
+    const QRegularExpression gncVersionExp("<gnc-v(\\d+)");
+    if (!(gncVersionExp.match(txt).hasMatch())) {
         return false;
     }
 
diff --git a/kmymoney/plugins/kbanking/kbanking.cpp b/kmymoney/plugins/kbanking/kbanking.cpp
index 3be639444..28a60dd23 100644
--- a/kmymoney/plugins/kbanking/kbanking.cpp
+++ b/kmymoney/plugins/kbanking/kbanking.cpp
@@ -21,7 +21,6 @@
 #include <QLabel>
 #include <QLayout>
 #include <QRadioButton>
-#include <QRegExp>
 #include <QRegularExpression>
 #include <QStringList>
 #include <QTimer>
@@ -97,7 +96,8 @@ public:
         QString gwenProxy = QString::fromLocal8Bit(qgetenv("GWEN_PROXY"));
         if (gwenProxy.isEmpty()) {
             std::unique_ptr<KConfig> cfg = std::unique_ptr<KConfig>(new KConfig("kioslaverc"));
-            QRegExp exp("(\\w+://)?([^/]{2}.+:\\d+)");
+            const QRegularExpression exp(QLatin1String("(\\w+://)?([^/]{2}.+:\\d+)"));
+            QRegularExpressionMatch proxyMatch;
             QString proxy;
 
             KConfigGroup grp = cfg->group("Proxy Settings");
@@ -108,9 +108,10 @@ public:
 
             case 1: // manual specified
                 proxy = grp.readEntry("httpsProxy");
+                proxyMatch = exp.match(proxy);
                 qDebug("KDE https proxy setting is '%s'", qPrintable(proxy));
-                if (exp.exactMatch(proxy)) {
-                    proxy = exp.cap(2);
+                if (proxyMatch.hasMatch()) {
+                    proxy = proxyMatch.captured(2);
                     qDebug("Setting GWEN_PROXY to '%s'", qPrintable(proxy));
                     if (!qputenv("GWEN_PROXY", qPrintable(proxy))) {
                         qDebug("Unable to setup GWEN_PROXY");
@@ -451,9 +452,10 @@ AB_ACCOUNT_SPEC* KBanking::aqbAccount(const QString& accountId) const
 QString KBanking::stripLeadingZeroes(const QString& s) const
 {
     QString rc(s);
-    QRegExp exp("^(0*)([^0].*)");
-    if (exp.exactMatch(s)) {
-        rc = exp.cap(2);
+    const QRegularExpression stripZeroExp(QLatin1String("^(0*)([^0].*)"));
+    const auto number(stripZeroExp.match(s));
+    if (number.hasMatch()) {
+        rc = number.captured(2);
     }
     return rc;
 }
@@ -1256,18 +1258,21 @@ void KBankingExt::_xaToStatement(MyMoneyStatement &ks,
         bool needExtract = true;
         QStringList::const_iterator it_s;
         for (it_s = exceptions.constBegin(); needExtract && it_s != exceptions.constEnd(); ++it_s) {
-            QRegExp exp(*it_s, Qt::CaseInsensitive);
-            if (exp.indexIn(kt.m_strMemo) != -1) {
+            const QRegularExpression exceptionExp(*it_s, QRegularExpression::CaseInsensitiveOption);
+            const auto memo(exceptionExp.match(kt.m_strMemo));
+            if (memo.hasMatch()) {
                 needExtract = false;
             }
         }
         if (needExtract) {
-            QRegExp expPayee(rePayee, Qt::CaseInsensitive);
-            QRegExp expMemo(reMemo, Qt::CaseInsensitive);
-            if (expPayee.indexIn(kt.m_strMemo) != -1) {
-                kt.m_strPayee = expPayee.cap(1);
-                if (expMemo.indexIn(kt.m_strMemo) != -1) {
-                    kt.m_strMemo = expMemo.cap(1);
+            const QRegularExpression payeeExp(rePayee, QRegularExpression::CaseInsensitiveOption);
+            const QRegularExpression memoExp(reMemo, QRegularExpression::CaseInsensitiveOption);
+            const auto payee(payeeExp.match(kt.m_strMemo));
+            const auto memo(memoExp.match(kt.m_strMemo));
+            if (payee.hasMatch()) {
+                kt.m_strPayee = payee.captured(1);
+                if (memo.hasMatch()) {
+                    kt.m_strMemo = memo.captured(1);
                 }
             }
         }
@@ -1310,7 +1315,7 @@ void KBankingExt::_xaToStatement(MyMoneyStatement &ks,
         // different nowadays, we make sure to use 100 for the
         // duplicate detection
         QString tmpVal = kt.m_amount.formatMoney(100, false);
-        tmpVal.remove(QRegExp("[,\\.]"));
+        tmpVal.remove(QRegularExpression(QLatin1String("[,\\.]")));
         tmpVal += QLatin1String("/100");
         h = MyMoneyTransaction::hash(tmpVal, h);
     } else {
diff --git a/kmymoney/plugins/kbanking/widgets/chiptandialog.cpp b/kmymoney/plugins/kbanking/widgets/chiptandialog.cpp
index d19aa4e4c..e3ded017d 100644
--- a/kmymoney/plugins/kbanking/widgets/chiptandialog.cpp
+++ b/kmymoney/plugins/kbanking/widgets/chiptandialog.cpp
@@ -11,12 +11,13 @@
 
 // Qt Includes
 #include <QMetaObject>
-#include <QQuickView>
-#include <QQuickItem>
 #include <QPushButton>
-#include <QRegExpValidator>
+#include <QQuickItem>
+#include <QQuickView>
+#include <QRegularExpressionValidator>
 #include <QStandardPaths>
 
+// KDE Includes
 #include <KLocalizedString>
 
 // Project Includes
@@ -106,7 +107,7 @@ QString chipTanDialog::tan()
 
 void chipTanDialog::setTanLimits(const int& minLength, const int& maxLength)
 {
-    ui->tanInput->setValidator(new QRegExpValidator(QRegExp(QString("\\d{%1,%2}").arg(minLength).arg(maxLength)), ui->tanInput));
+    ui->tanInput->setValidator(new QRegularExpressionValidator(QRegularExpression(QStringLiteral("\\d{%1,%2}").arg(minLength).arg(maxLength)), ui->tanInput));
 }
 
 int chipTanDialog::flickerFieldWidth()
diff --git a/kmymoney/plugins/kbanking/widgets/phototandialog.cpp b/kmymoney/plugins/kbanking/widgets/phototandialog.cpp
index a71c4047c..9b19be26d 100644
--- a/kmymoney/plugins/kbanking/widgets/phototandialog.cpp
+++ b/kmymoney/plugins/kbanking/widgets/phototandialog.cpp
@@ -10,7 +10,7 @@
 
 // Qt Includes
 #include <QPushButton>
-#include <QRegExpValidator>
+#include <QRegularExpressionValidator>
 
 #include <KLocalizedString>
 
@@ -78,7 +78,7 @@ QString photoTanDialog::tan()
 
 void photoTanDialog::setTanLimits(const int& minLength, const int& maxLength)
 {
-    ui->tanInput->setValidator(new QRegExpValidator(QRegExp(QString("\\d{%1,%2}").arg(minLength).arg(maxLength)), ui->tanInput));
+    ui->tanInput->setValidator(new QRegularExpressionValidator(QRegularExpression(QStringLiteral("\\d{%1,%2}").arg(minLength).arg(maxLength)), ui->tanInput));
 }
 
 void photoTanDialog::tanInputChanged(const QString& input)
diff --git a/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp b/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp
index 2e1aae0c8..9a33a147f 100644
--- a/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp
+++ b/kmymoney/plugins/ofx/import/dialogs/konlinebankingsetupwizard.cpp
@@ -11,7 +11,7 @@
 #include <QCheckBox>
 #include <QLabel>
 #include <QProgressDialog>
-#include <QRegExp>
+#include <QRegularExpression>
 #include <QStandardPaths>
 #include <QTabWidget>
 #include <QTextCodec>
@@ -357,13 +357,14 @@ bool KOnlineBankingSetupWizard::finishLoginPage()
         // https://ofxblog.wordpress.com/2007/06/06/ofx-appid-and-appver-for-intuit-products/
         // https://ofxblog.wordpress.com/2007/06/06/ofx-appid-and-appver-for-microsoft-money/
         QString appId = m_appId->appId();
-        QRegExp exp("(.*):(.*)");
-        if (exp.indexIn(appId) != -1) {
-            strncpy(fi.appid, exp.cap(1).toLatin1(), OFX_APPID_LENGTH - 1);
-            if (exp.cap(2).isEmpty()) {
+        const QRegularExpression appVersionExp(QLatin1String("(.*):(.*)"));
+        const auto appVersion(appVersionExp.match(appId));
+        if (appVersion.hasMatch()) {
+            strncpy(fi.appid, appVersion.captured(1).toLatin1(), OFX_APPID_LENGTH - 1);
+            if (appVersion.captured(2).isEmpty()) {
                 strncpy(fi.appver, m_applicationEdit->text().toLatin1(), OFX_APPVER_LENGTH - 1);
             } else {
-                strncpy(fi.appver, exp.cap(2).toLatin1(), OFX_APPVER_LENGTH - 1);
+                strncpy(fi.appver, appVersion.captured(2).toLatin1(), OFX_APPVER_LENGTH - 1);
             }
         } else {
             strncpy(fi.appid, "QWIN", OFX_APPID_LENGTH - 1);
diff --git a/kmymoney/plugins/ofx/import/dialogs/mymoneyofxconnector.cpp b/kmymoney/plugins/ofx/import/dialogs/mymoneyofxconnector.cpp
index 5f119d025..b58f0387a 100644
--- a/kmymoney/plugins/ofx/import/dialogs/mymoneyofxconnector.cpp
+++ b/kmymoney/plugins/ofx/import/dialogs/mymoneyofxconnector.cpp
@@ -18,7 +18,6 @@
 #include <QDateTime>
 #include <QDebug>
 #include <QList>
-#include <QRegExp>
 #include <QRegularExpression>
 #include <QRegularExpressionMatch>
 #include <QTextCodec>
@@ -168,7 +167,7 @@ const QString OfxAppVersion::appId() const
 
 bool OfxAppVersion::isValid() const
 {
-    QRegExp exp(".+:\\d+");
+    const QRegularExpression validAppVersionExp(QRegularExpression::anchoredPattern(QLatin1String(".+:\\d+")));
     QString app = m_combo->currentText();
     if (m_appMap[app].endsWith(':')) {
         if (m_versionEdit) {
@@ -179,7 +178,7 @@ bool OfxAppVersion::isValid() const
     } else {
         app = m_appMap[app];
     }
-    return exp.exactMatch(app);
+    return validAppVersionExp.match(app).hasMatch();
 }
 
 MyMoneyOfxConnector::MyMoneyOfxConnector(const MyMoneyAccount& _account):
@@ -303,19 +302,21 @@ OfxAccountData::AccountType MyMoneyOfxConnector::accounttype() const
     // This is a bit of a personalized hack.  Sometimes we may want to override the
     // ofx type for an account.  For now, I will stash it in the notes!
 
-    QRegExp rexp("OFXTYPE:([A-Z]*)");
-    if (rexp.indexIn(m_account.description()) != -1) {
-        QString override = rexp.cap(1);
-        qDebug() << "MyMoneyOfxConnector::accounttype() overriding to " << result;
+    const QRegularExpression accountTypeExp(QLatin1String("OFXTYPE:([A-Z]*)"));
+    const auto accountType(accountTypeExp.match(m_account.description()));
+    if (accountType.hasMatch()) {
+        const auto override = accountType.captured(1);
 
-        if (override == "BANK")
+        if (override == QLatin1String("BANK"))
             result = OfxAccountData::OFX_CHECKING;
-        else if (override == "CC")
+        else if (override == QLatin1String("CC"))
             result = OfxAccountData::OFX_CREDITCARD;
-        else if (override == "INV")
+        else if (override == QLatin1String("INV"))
             result = OfxAccountData::OFX_INVESTMENT;
-        else if (override == "MONEYMARKET")
+        else if (override == QLatin1String("MONEYMARKET"))
             result = OfxAccountData::OFX_MONEYMRKT;
+
+        qDebug() << "MyMoneyOfxConnector::accounttype() overriding to " << result;
     }
 
     return result;
diff --git a/kmymoney/plugins/ofx/import/ofxpartner.cpp b/kmymoney/plugins/ofx/import/ofxpartner.cpp
index 87ae6cac5..f8b987f1c 100644
--- a/kmymoney/plugins/ofx/import/ofxpartner.cpp
+++ b/kmymoney/plugins/ofx/import/ofxpartner.cpp
@@ -11,18 +11,17 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QDateTime>
-#include <QEventLoop>
-#include <QFileInfo>
 #include <QApplication>
-#include <QRegExp>
+#include <QDateTime>
+#include <QDebug>
 #include <QDir>
-#include <QFile>
-#include <QTextStream>
 #include <QDomDocument>
-#include <QDebug>
+#include <QEventLoop>
+#include <QFile>
+#include <QFileInfo>
 #include <QRegularExpression>
 #include <QRegularExpressionMatch>
+#include <QTextStream>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -147,17 +146,18 @@ QStringList FipidForBank(const QString& bank)
 QString extractNodeText(QDomElement& node, const QString& name)
 {
     QString res;
-    QRegExp exp("([^/]+)/?([^/].*)?");
-    if (exp.indexIn(name) != -1) {
-        QDomNodeList olist = node.elementsByTagName(exp.cap(1));
+    const QRegularExpression exp(QLatin1String("([^/]+)/?([^/].*)?"));
+    const auto match(exp.match(name));
+    if (match.hasMatch()) {
+        QDomNodeList olist = node.elementsByTagName(match.captured(1));
         if (olist.count()) {
             QDomNode onode = olist.item(0);
             if (onode.isElement()) {
                 QDomElement elo = onode.toElement();
-                if (exp.cap(2).isEmpty()) {
+                if (match.captured(2).isEmpty()) {
                     res = elo.text();
                 } else {
-                    res = extractNodeText(elo, exp.cap(2));
+                    res = extractNodeText(elo, match.captured(2));
                 }
             }
         }
@@ -168,17 +168,18 @@ QString extractNodeText(QDomElement& node, const QString& name)
 QString extractNodeText(QDomDocument& doc, const QString& name)
 {
     QString res;
-    QRegExp exp("([^/]+)/?([^/].*)?");
-    if (exp.indexIn(name) != -1) {
-        QDomNodeList olist = doc.elementsByTagName(exp.cap(1));
+    const QRegularExpression exp(QLatin1String("([^/]+)/?([^/].*)?"));
+    const auto match(exp.match(name));
+    if (match.hasMatch()) {
+        QDomNodeList olist = doc.elementsByTagName(match.captured(1));
         if (olist.count()) {
             QDomNode onode = olist.item(0);
             if (onode.isElement()) {
                 QDomElement elo = onode.toElement();
-                if (exp.cap(2).isEmpty()) {
+                if (match.captured(2).isEmpty()) {
                     res = elo.text();
                 } else {
-                    res = extractNodeText(elo, exp.cap(2));
+                    res = extractNodeText(elo, match.captured(2));
                 }
             }
         }
diff --git a/kmymoney/plugins/qif/config/mymoneyqifprofile.cpp b/kmymoney/plugins/qif/config/mymoneyqifprofile.cpp
index a4704fdf1..5dfce0508 100644
--- a/kmymoney/plugins/qif/config/mymoneyqifprofile.cpp
+++ b/kmymoney/plugins/qif/config/mymoneyqifprofile.cpp
@@ -9,9 +9,9 @@
 // QT Includes
 
 #include <QList>
-#include <QRegExp>
-#include <QVector>
 #include <QLocale>
+#include <QRegularExpression>
+#include <QVector>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -59,7 +59,7 @@ public:
 
 void MyMoneyQifProfile::Private::dissectDate(QVector<QString>& parts, const QString& txt) const
 {
-    QRegExp nonDelimChars("[ 0-9a-zA-Z]");
+    const QRegularExpression nonDelimChars(QLatin1String("[ 0-9a-zA-Z]"));
     int part = 0;                 // the current part we scan
     int pos;             // the current scan position
     int maxPartSize = txt.length() > 6 ? 4 : 2;
@@ -70,7 +70,8 @@ void MyMoneyQifProfile::Private::dissectDate(QVector<QString>& parts, const QStr
 
     // separate the parts of the date and keep the locations of the delimiters
     for (pos = 0; pos < txt.length() && part < 3; ++pos) {
-        if (nonDelimChars.indexIn(txt[pos]) == -1) {
+        const auto nonDelimMatch(nonDelimChars.match(txt[pos]));
+        if (!nonDelimMatch.hasMatch()) {
             if (!lastWasDelim) {
                 ++part;
                 maxPartSize = 0;         // make sure to pick the right one depending if next char is numeric or not
@@ -810,7 +811,8 @@ void MyMoneyQifProfile::autoDetect(const QStringList& lines)
     // 2 - transactions
     // 3 - prices
     int section = 0;
-    QRegExp price("\"(.*)\",(.*),\"(.*)\"");
+    const QRegularExpression priceExp(QLatin1String("\"(.*)\",(.*),\"(.*)\""));
+    QRegularExpressionMatch priceMatch;
     for (it = lines.begin(); it != lines.end(); ++it) {
         QChar c((*it)[0]);
         if (c == '!') {
@@ -854,9 +856,10 @@ void MyMoneyQifProfile::autoDetect(const QStringList& lines)
             }
             break;
         case 3:
-            if (price.indexIn(*it) != -1) {
-                scanNumeric(price.cap(2), m_decimal['P'], m_thousands['P']);
-                scanDate(price.cap(3));
+            priceMatch = priceExp.match(*it);
+            if (priceMatch.hasMatch()) {
+                scanNumeric(priceMatch.captured(2), m_decimal['P'], m_thousands['P']);
+                scanDate(priceMatch.captured(3));
                 ++datesScanned;
             }
             break;
@@ -942,10 +945,11 @@ void MyMoneyQifProfile::autoDetect(const QStringList& lines)
 void MyMoneyQifProfile::scanNumeric(const QString& txt, QChar& decimal, QChar& thousands) const
 {
     QChar first, second;
-    QRegExp numericChars("[0-9-()]");
+    const QRegularExpression numericCharsExp(QLatin1String("[0-9-()]"));
     for (int i = 0; i < txt.length(); ++i) {
         const QChar& c = txt[i];
-        if (numericChars.indexIn(c) == -1) {
+        const auto numericChars(numericCharsExp.match(c));
+        if (!numericChars.hasMatch()) {
             if (c == '.' || c == ',') {
                 first = second;
                 second = c;
diff --git a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
index fb3e0afd4..12adc8ebb 100644
--- a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
+++ b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
@@ -14,14 +14,14 @@
 // ----------------------------------------------------------------------------
 // QT Headers
 
-#include <QFile>
-#include <QStringList>
-#include <QTimer>
-#include <QRegExp>
 #include <QBuffer>
 #include <QByteArray>
-#include <QInputDialog>
 #include <QDir>
+#include <QFile>
+#include <QInputDialog>
+#include <QRegularExpression>
+#include <QStringList>
+#include <QTimer>
 
 // ----------------------------------------------------------------------------
 // KDE Headers
@@ -211,14 +211,14 @@ bool MyMoneyQifReader::Private::isTransfer(QString& tmp, const QString& leftDeli
     // S[Mehrwertsteuer]/_VATCode_N_I          (The '/' is the Quicken class symbol)
     //
     // so extracting is a bit more complex and we use a regexp for it
-    QRegExp exp(QString("\\%1(.*)\\%2(.*)").arg(leftDelim, rightDelim));
-
-    bool rc;
-    if ((rc = (exp.indexIn(tmp) != -1)) == true) {
-        tmp = exp.cap(1) + exp.cap(2);
+    const QRegularExpression transferExp(QStringLiteral("\\%1(.*)\\%2(.*)").arg(leftDelim, rightDelim));
+    const auto transfer(transferExp.match(tmp));
+    if (transfer.hasMatch()) {
+        tmp = transfer.captured(1) + transfer.captured(2);
         tmp = tmp.trimmed();
+        return true;
     }
-    return rc;
+    return false;
 }
 
 eMyMoney::Split::State MyMoneyQifReader::Private::reconcileState(const QString& state) const
@@ -1467,7 +1467,7 @@ void MyMoneyQifReader::processInvestmentTransactionEntry()
     // dividend payment
     if ((xAction == true)
             || (d->isTransfer(tmp, m_qifProfile.accountDelimiter().left(1), m_qifProfile.accountDelimiter().mid(1, 1)) == true)) {
-        tmp = tmp.remove(QRegExp("[\\[\\]]"));                 //  xAction != true so ignore any'[ and ]'
+        tmp = tmp.remove(QRegularExpression(QLatin1String("[\\[\\]]"))); //  xAction != true so ignore any'[ and ]'
         if (!tmp.isEmpty()) {                                  // use 'L' record name
             tr.m_strBrokerageAccount = tmp;
             transferAccount(tmp);                                // make sure the account exists
@@ -1476,7 +1476,7 @@ void MyMoneyQifReader::processInvestmentTransactionEntry()
             transferAccount(m_account.brokerageName());          // make sure the account exists
         }
     } else {
-        tmp = tmp.remove(QRegExp("[\\[\\]]"));                 //  xAction != true so ignore any'[ and ]'
+        tmp = tmp.remove(QRegularExpression(QLatin1String("[\\[\\]]"))); //  xAction != true so ignore any'[ and ]'
         tr.m_strInterestCategory = tmp;
         tr.m_strBrokerageAccount = m_account.brokerageName();
     }
@@ -1910,8 +1910,8 @@ const QString MyMoneyQifReader::processAccountEntry(bool resetAccountId)
         account.setLastReconciliationDate(m_qifProfile.date(tmp));
 
     QifEntryTypeE transactionType = EntryTransaction;
-    QString type = extractLine('T').toLower().remove(QRegExp("\\s+"));
-    if (type == m_qifProfile.profileType().toLower().remove(QRegExp("\\s+"))) {
+    QString type = extractLine('T').toLower().remove(QRegularExpression(QLatin1String("\\s+")));
+    if (type == m_qifProfile.profileType().toLower().remove(QRegularExpression(QLatin1String("\\s+")))) {
         account.setAccountType(eMyMoney::Account::Type::Checkings);
     } else if (type == "ccard" || type == "creditcard") {
         account.setAccountType(eMyMoney::Account::Type::CreditCard);
@@ -2029,13 +2029,14 @@ void MyMoneyQifReader::processPriceEntry()
     QStringList::const_iterator it_line = m_qifEntry.constBegin();
 
     // Make a price for each line
-    QRegExp priceExp("\"(.*)\",(.*),\"(.*)\"");
+    const QRegularExpression priceExp(QLatin1String("\"(.*)\",(.*),\"(.*)\""));
     while (it_line != m_qifEntry.constEnd()) {
-        if (priceExp.indexIn(*it_line) != -1) {
+        const auto priceMatch(priceExp.match(*it_line));
+        if (priceMatch.hasMatch()) {
             MyMoneyStatement::Price price;
-            price.m_strSecurity = priceExp.cap(1);
-            QString pricestr = priceExp.cap(2);
-            QString datestr = priceExp.cap(3);
+            price.m_strSecurity = priceMatch.captured(1);
+            QString pricestr = priceMatch.captured(2);
+            QString datestr = priceMatch.captured(3);
             qDebug() << "Price:" << price.m_strSecurity << " / " << pricestr << " / " << datestr;
 
             // Only add the price if the date is valid.  If invalid, fail silently.  See note above.
diff --git a/kmymoney/plugins/sql/mymoneydbdef.cpp b/kmymoney/plugins/sql/mymoneydbdef.cpp
index 910f3547d..22bc7ed9f 100644
--- a/kmymoney/plugins/sql/mymoneydbdef.cpp
+++ b/kmymoney/plugins/sql/mymoneydbdef.cpp
@@ -507,7 +507,7 @@ const QString MyMoneyDbDef::generateSQL(const QExplicitlySharedDataPointer<MyMon
         if ((*fit)->name() == "updateInProgress")
             replace = enclose("N");
 
-        qs.replace(QRegExp(toReplace + "(?=[,\\s\\)])"), replace);
+        qs.replace(QRegularExpression(toReplace + QLatin1String("(?=[,\\s\\)])")), replace);
         // only replace parameters followed by comma, whitespace, closing parenthesis - otherwise
         // conflicts may occur if one parameter starts with the name of another one.
     }
diff --git a/kmymoney/plugins/sql/mymoneystoragesql_p.h b/kmymoney/plugins/sql/mymoneystoragesql_p.h
index 6598591dc..605977c02 100644
--- a/kmymoney/plugins/sql/mymoneystoragesql_p.h
+++ b/kmymoney/plugins/sql/mymoneystoragesql_p.h
@@ -1959,7 +1959,7 @@ public:
     ulong calcHighId(ulong i, const QString& id)
     {
         QString nid = id;
-        ulong high = (ulong) nid.remove(QRegExp("[A-Z]*")).toULongLong();
+        ulong high = (ulong)nid.remove(QRegularExpression(QLatin1String("[A-Z]*"))).toULongLong();
         return std::max(high, i);
     }
 
diff --git a/kmymoney/plugins/views/reports/core/pivottable.cpp b/kmymoney/plugins/views/reports/core/pivottable.cpp
index ab6f614d9..acbfef78b 100644
--- a/kmymoney/plugins/views/reports/core/pivottable.cpp
+++ b/kmymoney/plugins/views/reports/core/pivottable.cpp
@@ -9,10 +9,10 @@
 
 // ----------------------------------------------------------------------------
 // QT Includes
-#include <QRegExp>
 #include <QFile>
-#include <QTextStream>
 #include <QList>
+#include <QRegularExpression>
+#include <QTextStream>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -21,23 +21,23 @@
 
 // ----------------------------------------------------------------------------
 // Project Includes
-#include "pivotgrid.h"
-#include "reportdebug.h"
-#include "kreportchartview.h"
+#include "journalmodel.h"
 #include "kmymoneysettings.h"
 #include "kmymoneyutils.h"
+#include "kreportchartview.h"
+#include "mymoneybudget.h"
+#include "mymoneyenums.h"
+#include "mymoneyexception.h"
+#include "mymoneyfile.h"
 #include "mymoneyforecast.h"
 #include "mymoneyprice.h"
-#include "mymoneyfile.h"
-#include "mymoneysecurity.h"
-#include "mymoneybudget.h"
 #include "mymoneyreport.h"
 #include "mymoneyschedule.h"
+#include "mymoneysecurity.h"
 #include "mymoneysplit.h"
 #include "mymoneytransaction.h"
-#include "mymoneyexception.h"
-#include "mymoneyenums.h"
-#include "journalmodel.h"
+#include "pivotgrid.h"
+#include "reportdebug.h"
 
 namespace KChart {
 class Widget;
@@ -1666,7 +1666,7 @@ QString PivotTable::renderHTML() const
 
     auto column = 0;
     while (column < m_numColumns)
-        result += QString("<th%1>%2</th>").arg(headerspan, QString(m_columnHeadings[column++]).replace(QRegExp(" "), "<br>"));
+        result += QString("<th%1>%2</th>").arg(headerspan, QString(m_columnHeadings[column++]).replace(QRegularExpression(QLatin1String(" ")), "<br>"));
 
     if (m_config.isShowingRowTotals())
         result += QString("<th%1>%2</th>").arg(headerspan).arg(i18nc("Total balance", "Total"));
@@ -1818,13 +1818,15 @@ QString PivotTable::renderHTML() const
 
                         // don't show closed accounts if they have not been used
                         if (!rowname.isClosed() || isUsed) {
-                            innergroupdata += QString("<tr class=\"row-%1\"%2><td%3 class=\"left\" style=\"text-indent: %4.0em\">%5%6</td>")
-                                              .arg(rownum & 0x01 ? "even" : "odd")
-                                              .arg(rowname.isTopLevel() ? " id=\"topparent\"" : "")
-                                              .arg("") //.arg((*it_row).m_total.isZero() ? colspan : "")  // colspan the distance if this row will be blank
-                                              .arg(rowname.hierarchyDepth() - 1)
-                                              .arg(rowname.name().replace(QRegExp(" "), " ").replace("<", "<").replace(">", ">"))
-                                              .arg((m_config.isConvertCurrency() || !rowname.isForeignCurrency()) ? QString() : QString(" (%1)").arg(rowname.currency().id()));
+                            innergroupdata +=
+                                QString("<tr class=\"row-%1\"%2><td%3 class=\"left\" style=\"text-indent: %4.0em\">%5%6</td>")
+                                    .arg(rownum & 0x01 ? "even" : "odd")
+                                    .arg(rowname.isTopLevel() ? " id=\"topparent\"" : "")
+                                    .arg("") //.arg((*it_row).m_total.isZero() ? colspan : "")  // colspan the distance if this row will be blank
+                                    .arg(rowname.hierarchyDepth() - 1)
+                                    .arg(rowname.name().replace(QRegularExpression(QLatin1String(" ")), " ").replace("<", "<").replace(">", ">"))
+                                    .arg((m_config.isConvertCurrency() || !rowname.isForeignCurrency()) ? QString()
+                                                                                                        : QString(" (%1)").arg(rowname.currency().id()));
 
                             // Don't print this row if it's going to be all zeros
                             // TODO: Uncomment this, and deal with the case where the data
@@ -1873,11 +1875,12 @@ QString PivotTable::renderHTML() const
                         ReportAccount rowname = (*it_innergroup).begin().key();
                         isUsed |= !rowname.isClosed();
                         finalRow = QString("<tr class=\"row-%1\"%2><td class=\"left\" style=\"text-indent: %3.0em;\">%5%6</td>")
-                                   .arg(rownum & 0x01 ? "even" : "odd")
-                                   .arg(m_config.detailLevel() == eMyMoney::Report::DetailLevel::All ? "id=\"solo\"" : "")
-                                   .arg(rowname.hierarchyDepth() - 1)
-                                   .arg(rowname.name().replace(QRegExp(" "), " ").replace("<", "<").replace(">", ">"))
-                                   .arg((m_config.isConvertCurrency() || !rowname.isForeignCurrency()) ? QString() : QString(" (%1)").arg(rowname.currency().id()));
+                                       .arg(rownum & 0x01 ? "even" : "odd")
+                                       .arg(m_config.detailLevel() == eMyMoney::Report::DetailLevel::All ? "id=\"solo\"" : "")
+                                       .arg(rowname.hierarchyDepth() - 1)
+                                       .arg(rowname.name().replace(QRegularExpression(QLatin1String(" ")), " ").replace("<", "<").replace(">", ">"))
+                                       .arg((m_config.isConvertCurrency() || !rowname.isForeignCurrency()) ? QString()
+                                                                                                           : QString(" (%1)").arg(rowname.currency().id()));
                     }
 
                     // Finish the row started above, unless told not to
diff --git a/kmymoney/plugins/views/reports/core/tests/pivottable-test.cpp b/kmymoney/plugins/views/reports/core/tests/pivottable-test.cpp
index 86893418e..58e06595c 100644
--- a/kmymoney/plugins/views/reports/core/tests/pivottable-test.cpp
+++ b/kmymoney/plugins/views/reports/core/tests/pivottable-test.cpp
@@ -1096,8 +1096,7 @@ void PivotTableTest::testHtmlEncoding()
     QString html = networth_f.renderReport(QLatin1String("html"), encoding,
                                            filter.name(), false);
 
-    QRegExp rx(QString::fromLatin1("*<meta * charset=" + encoding + "*>*"));
-    rx.setPatternSyntax(QRegExp::Wildcard);
-    rx.setCaseSensitivity(Qt::CaseInsensitive);
-    QVERIFY(rx.exactMatch(html));
+    const QRegularExpression rx(QLatin1String("^.*<meta .* charset=" + encoding + ".*>.*"),
+                                QRegularExpression::CaseInsensitiveOption | QRegularExpression::DotMatchesEverythingOption);
+    QVERIFY(rx.match(html).hasMatch());
 }
diff --git a/kmymoney/plugins/xml/kcm_xmlstorage.cpp b/kmymoney/plugins/xml/kcm_xmlstorage.cpp
index 887dfde6d..e0c90960f 100644
--- a/kmymoney/plugins/xml/kcm_xmlstorage.cpp
+++ b/kmymoney/plugins/xml/kcm_xmlstorage.cpp
@@ -10,6 +10,8 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
+#include <QRegularExpression>
+
 // ----------------------------------------------------------------------------
 // KDE Includes
 
@@ -99,9 +101,10 @@ void XMLStorageSettingsWidget::slotIdChanged()
 
             // if we have a master key, we store it in the hidden widget
             if (m_masterKeyCombo->currentIndex() != 0) {
-                QRegExp keyExp(".* \\((.*)\\)");
-                if (keyExp.indexIn(m_masterKeyCombo->currentText()) != -1) {
-                    kcfg_GpgRecipient->setText(keyExp.cap(1));
+                const QRegularExpression keyExp(".* \\((.*)\\)");
+                const auto key(keyExp.match(m_masterKeyCombo->currentText()));
+                if (key.hasMatch()) {
+                    kcfg_GpgRecipient->setText(key.captured(1));
                 }
             }
 
@@ -123,9 +126,10 @@ void XMLStorageSettingsWidget::showEvent(QShowEvent * event)
     QString masterKey;
 
     if (m_masterKeyCombo->currentIndex() != 0) {
-        QRegExp keyExp(".* \\((.*)\\)");
-        if (keyExp.indexIn(m_masterKeyCombo->currentText()) != -1) {
-            masterKey = keyExp.cap(1);
+        const QRegularExpression keyExp(".* \\((.*)\\)");
+        const auto key(keyExp.match(m_masterKeyCombo->currentText()));
+        if (key.hasMatch()) {
+            masterKey = key.captured(1);
         }
     } else
         masterKey = kcfg_GpgRecipient->text();
diff --git a/kmymoney/plugins/xml/ksettingsgpg.cpp b/kmymoney/plugins/xml/ksettingsgpg.cpp
index 6d9c86bb3..656d98948 100644
--- a/kmymoney/plugins/xml/ksettingsgpg.cpp
+++ b/kmymoney/plugins/xml/ksettingsgpg.cpp
@@ -10,7 +10,8 @@
 // QT Includes
 
 #include <QCheckBox>
-#include <QRegExp>
+#include <QRegularExpression>
+#include <QRegularExpressionMatch>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -134,9 +135,10 @@ void KSettingsGpg::slotIdChanged()
 
             // if we have a master key, we store it in the hidden widget
             if (d->ui->m_masterKeyCombo->currentIndex() != 0) {
-                QRegExp keyExp(".* \\((.*)\\)");
-                if (keyExp.indexIn(d->ui->m_masterKeyCombo->currentText()) != -1) {
-                    d->ui->kcfg_GpgRecipient->setText(keyExp.cap(1));
+                const QRegularExpression keyExp(QLatin1String(".* \\((.*)\\)"));
+                const auto key(keyExp.match(d->ui->m_masterKeyCombo->currentText()));
+                if (key.hasMatch()) {
+                    d->ui->kcfg_GpgRecipient->setText(key.captured(1));
                 }
             }
 
@@ -159,9 +161,10 @@ void KSettingsGpg::showEvent(QShowEvent * event)
     QString masterKey;
 
     if (d->ui->m_masterKeyCombo->currentIndex() != 0) {
-        QRegExp keyExp(".* \\((.*)\\)");
-        if (keyExp.indexIn(d->ui->m_masterKeyCombo->currentText()) != -1) {
-            masterKey = keyExp.cap(1);
+        const QRegularExpression keyExp(QLatin1String(".* \\((.*)\\)"));
+        const auto key(keyExp.match(d->ui->m_masterKeyCombo->currentText()));
+        if (key.hasMatch()) {
+            masterKey = key.captured(1);
         }
     } else
         masterKey = d->ui->kcfg_GpgRecipient->text();
diff --git a/kmymoney/plugins/xml/mymoneystorageanon.cpp b/kmymoney/plugins/xml/mymoneystorageanon.cpp
index 5a1953b97..953f11c6c 100644
--- a/kmymoney/plugins/xml/mymoneystorageanon.cpp
+++ b/kmymoney/plugins/xml/mymoneystorageanon.cpp
@@ -118,7 +118,7 @@ void MyMoneyStorageANON::writePayee(QDomElement& payee, const MyMoneyPayee& _p)
     bool ignoreCase;
     QStringList keys;
     auto matchType = p.matchData(ignoreCase, keys);
-    QRegExp exp("[A-Za-z]");
+    const QRegularExpression exp("[A-Za-z]");
     p.setMatchData(matchType, ignoreCase, keys.join(";").replace(exp, "x").split(';'));
 
     // Data from plugins cannot be estranged, yet.
diff --git a/kmymoney/plugins/xml/xmlstorage.cpp b/kmymoney/plugins/xml/xmlstorage.cpp
index 0767f443e..7e93a1fbd 100644
--- a/kmymoney/plugins/xml/xmlstorage.cpp
+++ b/kmymoney/plugins/xml/xmlstorage.cpp
@@ -189,9 +189,10 @@ bool XMLStorage::open(const QUrl &url)
     else
         ungetString(qfile, qbaFileHeader.data(), 70);
 
-    QRegExp kmyexp("<!DOCTYPE KMYMONEY-FILE>");
+    const QRegularExpression kmyexp(QLatin1String("<!DOCTYPE KMYMONEY-FILE>"));
     QByteArray txt(qbaFileHeader, 70);
-    if (kmyexp.indexIn(txt) == -1)
+    const auto docType(kmyexp.match(txt));
+    if (!docType.hasMatch())
         return false;
 
     MyMoneyStorageXML pReader;
@@ -378,9 +379,10 @@ bool XMLStorage::saveAs()
                 rc = save(newURL);
             else {
                 appInterface()->writeFilenameURL(newURL);
-                QRegExp keyExp(".* \\((.*)\\)");
-                if (keyExp.indexIn(selectedKeyName) != -1) {
-                    m_encryptionKeys = keyExp.cap(1);
+                const QRegularExpression keyExp(QLatin1String(".* \\((.*)\\)"));
+                const auto key(keyExp.match(selectedKeyName));
+                if (key.hasMatch()) {
+                    m_encryptionKeys = key.captured(1);
                     if (!m_additionalGpgKeys.isEmpty()) {
                         if (!m_encryptionKeys.isEmpty())
                             m_encryptionKeys.append(QLatin1Char(','));
diff --git a/kmymoney/settings/kmymoneysettings_addons.cpp b/kmymoney/settings/kmymoneysettings_addons.cpp
index 70e449b5d..40374b324 100644
--- a/kmymoney/settings/kmymoneysettings_addons.cpp
+++ b/kmymoney/settings/kmymoneysettings_addons.cpp
@@ -6,8 +6,8 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QRegExp>
 #include <QFontDatabase>
+#include <QRegularExpression>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -102,10 +102,11 @@ QStringList KMyMoneySettings::listOfItems()
     QStringList list = itemList().split(',', QString::SkipEmptyParts);
 
     // now add all from 'all' that are missing in 'list'
-    QRegExp exp("-?(\\d+)");
+    const QRegularExpression exp(QLatin1String("-?(\\d+)"));
     QStringList::iterator it_s;
     for (it_s = all.begin(); it_s != all.end(); ++it_s) {
-        if ((exp.indexIn(*it_s) != -1) && !list.contains(exp.cap(1)) && !list.contains(QString("-%1").arg(exp.cap(1)))) {
+        const auto item(exp.match(*it_s));
+        if ((item.hasMatch()) && !list.contains(item.captured(1)) && !list.contains(QString("-%1").arg(item.captured(1)))) {
             list << *it_s;
         }
     }
diff --git a/kmymoney/tests/testutilities.cpp b/kmymoney/tests/testutilities.cpp
index 74def130c..d1525590b 100644
--- a/kmymoney/tests/testutilities.cpp
+++ b/kmymoney/tests/testutilities.cpp
@@ -6,12 +6,13 @@
 
 #include "testutilities.h"
 
-#include <QList>
-#include <QFile>
-#include <QTextStream>
+#include <QDebug>
 #include <QDomDocument>
 #include <QDomElement>
-#include <QDebug>
+#include <QFile>
+#include <QList>
+#include <QRegularExpression>
+#include <QTextStream>
 
 #include "mymoneyfile.h"
 #include "mymoneyexception.h"
@@ -434,9 +435,10 @@ void XMLandback(MyMoneyReport& filter)
 MyMoneyMoney searchHTML(const QString& _html, const QString& _search)
 {
     Q_UNUSED(_html)
-    QRegExp re(QString("%1[<>/td]*([\\-.0-9,]*)").arg(_search));
-    if (re.indexIn(_html) > -1) {
-        QString found = re.cap(1);
+    const QRegularExpression re(QStringLiteral("%1[<>/td]*([\\-.0-9,]*)").arg(_search));
+    const auto html(re.match(_html));
+    if (html.hasMatch()) {
+        auto found = html.captured(1);
         found.remove(',');
 
         return MyMoneyMoney(found.toDouble());
diff --git a/kmymoney/views/kmymoneyview.cpp b/kmymoney/views/kmymoneyview.cpp
index f121391d3..ba1d5c62d 100644
--- a/kmymoney/views/kmymoneyview.cpp
+++ b/kmymoney/views/kmymoneyview.cpp
@@ -17,7 +17,6 @@
 // QT Includes
 
 #include <QFile>
-#include <QRegExp>
 #include <QLayout>
 #include <QList>
 #include <QByteArray>
diff --git a/kmymoney/views/kpayeesview_p.h b/kmymoney/views/kpayeesview_p.h
index 594159b50..f65b132d8 100644
--- a/kmymoney/views/kpayeesview_p.h
+++ b/kmymoney/views/kpayeesview_p.h
@@ -17,6 +17,7 @@
 // QT Includes
 
 #include <QDesktopServices>
+#include <QRegularExpression>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -603,14 +604,15 @@ public:
                         // make sure we really need it and it is not caught by an existing regexp
                         QStringList::const_iterator it_k;
                         for (it_k = payeeNames.constBegin(); it_k != payeeNames.constEnd(); ++it_k) {
-                            QRegExp exp(*it_k, ignorecase ? Qt::CaseInsensitive : Qt::CaseSensitive);
-                            if (exp.indexIn(*it_n) != -1)
+                            const QRegularExpression exp(*it_k, ignorecase ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption);
+                            const auto payee(exp.match(*it_n));
+                            if (payee.hasMatch())
                                 break;
                         }
                         if (it_k == payeeNames.constEnd())
-                            payeeNames << QRegExp::escape(*it_n);
+                            payeeNames << QRegularExpression::escape(*it_n);
                     } else if (payeeNames.contains(*it_n) == 0)
-                        payeeNames << QRegExp::escape(*it_n);
+                        payeeNames << QRegularExpression::escape(*it_n);
                 }
 
                 // and update the payee in the engine context
diff --git a/kmymoney/views/ledgerview.cpp b/kmymoney/views/ledgerview.cpp
index 98e41d0ac..4cac6651f 100644
--- a/kmymoney/views/ledgerview.cpp
+++ b/kmymoney/views/ledgerview.cpp
@@ -17,6 +17,7 @@
 #include <QResizeEvent>
 #include <QScrollBar>
 #include <QSet>
+#include <QStackedWidget>
 #include <QToolTip>
 #include <QWidgetAction>
 
@@ -29,7 +30,6 @@
 #include <KMessageBox>
 #include <KMessageWidget>
 #include <KStandardGuiItem>
-#include <QStackedWidget>
 
 // ----------------------------------------------------------------------------
 // Project Includes
@@ -236,7 +236,7 @@ public:
             // found an account, update the action
             if (!acc.id().isEmpty()) {
                 auto name = acc.name();
-                name.replace(QRegExp("&(?!&)"), "&&");
+                name.replace(QRegularExpression(QLatin1String("&(?!&)")), QLatin1String("&&"));
                 gotoAccount->setEnabled(true);
                 gotoAccount->setText(i18nc("@action:inmenu open account", "Go to '%1'", name));
                 gotoAccount->setData(acc.id());
@@ -246,7 +246,7 @@ public:
                 auto payeeId = indexes.at(0).data(eMyMoney::Model::SplitPayeeIdRole).toString();
                 if (!payeeId.isEmpty()) {
                     auto name = indexes.at(0).data(eMyMoney::Model::SplitPayeeRole).toString();
-                    name.replace(QRegExp("&(?!&)"), "&&");
+                    name.replace(QRegularExpression(QLatin1String("&(?!&)")), QLatin1String("&&"));
                     gotoPayee->setEnabled(true);
                     gotoPayee->setText(i18nc("@action:inmenu open payee", "Go to '%1'", name));
                     gotoPayee->setData(payeeId);
diff --git a/kmymoney/widgets/kaccounttemplateselector.cpp b/kmymoney/widgets/kaccounttemplateselector.cpp
index 696ef6327..04bfd906d 100644
--- a/kmymoney/widgets/kaccounttemplateselector.cpp
+++ b/kmymoney/widgets/kaccounttemplateselector.cpp
@@ -51,9 +51,10 @@ public:
     {
         if (!templateHierarchy.contains(parent)
                 || templateHierarchy[parent] == 0) {
-            QRegExp exp("(.*):(.*)");
-            if (exp.indexIn(parent) != -1)
-                templateHierarchy[parent] = hierarchyItem(exp.cap(1), exp.cap(2));
+            const QRegularExpression hierarchyExp(QLatin1String("(.*):(.*)"));
+            const auto hierarchyParts(hierarchyExp.match(parent));
+            if (hierarchyParts.hasMatch())
+                templateHierarchy[parent] = hierarchyItem(hierarchyParts.captured(1), hierarchyParts.captured(2));
         }
         QTreeWidgetItem *item = new QTreeWidgetItem(templateHierarchy[parent]);
         item->setText(0, name);
@@ -145,13 +146,14 @@ public:
 
         ui->m_accountList->clear();
 
-        QRegExp exp("(.*):(.*)");
+        const QRegularExpression hierarchyExp(QLatin1String("(.*):(.*)"));
         for (QMap<QString, QTreeWidgetItem*>::iterator it_h = templateHierarchy.begin(); it_h != templateHierarchy.end(); ++it_h) {
-            if (exp.indexIn(it_h.key()) == -1) {
+            const auto hierarchyParts(hierarchyExp.match(it_h.key()));
+            if (!hierarchyParts.hasMatch()) {
                 (*it_h) = new QTreeWidgetItem(ui->m_accountList);
                 (*it_h)->setText(0, it_h.key());
             } else {
-                (*it_h) = hierarchyItem(exp.cap(1), exp.cap(2));
+                (*it_h) = hierarchyItem(hierarchyParts.captured(1), hierarchyParts.captured(2));
             }
             (*it_h)->setExpanded(true);
         }
diff --git a/kmymoney/widgets/kmymoneyaccountcombo.cpp b/kmymoney/widgets/kmymoneyaccountcombo.cpp
index 231c1d8f5..93086a958 100644
--- a/kmymoney/widgets/kmymoneyaccountcombo.cpp
+++ b/kmymoney/widgets/kmymoneyaccountcombo.cpp
@@ -9,12 +9,13 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QList>
+#include <QAction>
 #include <QEvent>
 #include <QKeyEvent>
-#include <QTreeView>
 #include <QLineEdit>
-#include <QAction>
+#include <QList>
+#include <QRegularExpression>
+#include <QTreeView>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -366,8 +367,8 @@ void KMyMoneyAccountCombo::makeCompletion(const QString& txt)
                 // clear the filter before setting it to a new value
                 filterModel->setFilterFixedString(QString());
                 if (txt.contains(MyMoneyFile::AccountSeparator) == 0) {
-                    const auto filterString = QString::fromLatin1("%1%2%3").arg(completionStr).arg(QRegExp::escape(txt)).arg(completionStr);
-                    filterModel->setFilterRegExp(QRegExp(filterString, Qt::CaseInsensitive));
+                    const auto filterString = QString::fromLatin1("%1%2%3").arg(completionStr).arg(QRegularExpression::escape(txt)).arg(completionStr);
+                    filterModel->setFilterRegularExpression(QRegularExpression(filterString, QRegularExpression::CaseInsensitiveOption));
                 } else {
                     QStringList parts = txt.split(MyMoneyFile::AccountSeparator /*, QString::SkipEmptyParts */);
                     QString pattern;
@@ -375,9 +376,9 @@ void KMyMoneyAccountCombo::makeCompletion(const QString& txt)
                     for (it = parts.begin(); it != parts.end(); ++it) {
                         if (pattern.length() > 1)
                             pattern += MyMoneyFile::AccountSeparator;
-                        pattern += QRegExp::escape(QString(*it).trimmed()) + completionStr;
+                        pattern += QRegularExpression::escape(QString(*it).trimmed()) + completionStr;
                     }
-                    filterModel->setFilterRegExp(QRegExp(pattern, Qt::CaseInsensitive));
+                    filterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
                     // if we don't have a match, we try it again, but this time
                     // we add a wildcard for the top level
                     if (filterModel->visibleItems() == 0) {
@@ -385,7 +386,7 @@ void KMyMoneyAccountCombo::makeCompletion(const QString& txt)
                         // clear the filter before setting it to a new value
                         filterModel->setFilterFixedString(QString());
                         pattern = pattern.prepend(completionStr + MyMoneyFile::AccountSeparator);
-                        filterModel->setFilterRegExp(QRegExp(pattern, Qt::CaseInsensitive));
+                        filterModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
                     }
                 }
 
diff --git a/kmymoney/widgets/kmymoneyaccountcompletion.cpp b/kmymoney/widgets/kmymoneyaccountcompletion.cpp
index 62c7da961..334072d88 100644
--- a/kmymoney/widgets/kmymoneyaccountcompletion.cpp
+++ b/kmymoney/widgets/kmymoneyaccountcompletion.cpp
@@ -10,7 +10,6 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QRegExp>
 #include <QLayout>
 
 // ----------------------------------------------------------------------------
@@ -75,7 +74,7 @@ void KMyMoneyAccountCompletion::slotMakeCompletion(const QString& txt)
 
     auto cnt = 0;
     if (txt.contains(MyMoneyFile::AccountSeparator) == 0) {
-        d->m_lastCompletion = QRegExp(QRegExp::escape(txt), Qt::CaseInsensitive);
+        d->m_lastCompletion = QRegularExpression(QRegularExpression::escape(txt), QRegularExpression::CaseInsensitiveOption);
         cnt = selector()->slotMakeCompletion(txt);
     } else {
         QStringList parts = txt.split(MyMoneyFile::AccountSeparator, QString::SkipEmptyParts);
@@ -84,16 +83,16 @@ void KMyMoneyAccountCompletion::slotMakeCompletion(const QString& txt)
         for (it = parts.begin(); it != parts.end(); ++it) {
             if (pattern.length() > 1)
                 pattern += MyMoneyFile::AccountSeparator;
-            pattern += QRegExp::escape(QString(*it).trimmed()) + ".*";
+            pattern += QRegularExpression::escape(QString(*it).trimmed()) + ".*";
         }
         pattern += '$';
-        d->m_lastCompletion = QRegExp(pattern, Qt::CaseInsensitive);
+        d->m_lastCompletion = QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption);
         cnt = selector()->slotMakeCompletion(d->m_lastCompletion);
         // if we don't have a match, we try it again, but this time
         // we add a wildcard for the top level
         if (cnt == 0) {
             pattern = pattern.insert(1, QString(".*") + MyMoneyFile::AccountSeparator);
-            d->m_lastCompletion = QRegExp(pattern, Qt::CaseInsensitive);
+            d->m_lastCompletion = QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption);
             cnt = selector()->slotMakeCompletion(d->m_lastCompletion);
         }
     }
diff --git a/kmymoney/widgets/kmymoneyaccountselector.cpp b/kmymoney/widgets/kmymoneyaccountselector.cpp
index a2be8928a..f06eca74b 100644
--- a/kmymoney/widgets/kmymoneyaccountselector.cpp
+++ b/kmymoney/widgets/kmymoneyaccountselector.cpp
@@ -10,11 +10,11 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
+#include <QIcon>
 #include <QList>
-#include <QVBoxLayout>
 #include <QPixmapCache>
 #include <QPushButton>
-#include <QIcon>
+#include <QVBoxLayout>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -24,11 +24,11 @@
 // ----------------------------------------------------------------------------
 // Project Includes
 
-#include "mymoneyfile.h"
+#include "dialogenums.h"
+#include "icons.h"
 #include "mymoneyaccount.h"
-#include "icons/icons.h"
 #include "mymoneyenums.h"
-#include "dialogenums.h"
+#include "mymoneyfile.h"
 #include "widgetenums.h"
 
 using namespace Icons;
@@ -171,11 +171,12 @@ QStringList KMyMoneyAccountSelector::accountList() const
     return accountList(QList<eMyMoney::Account::Type>());
 }
 
-bool KMyMoneyAccountSelector::match(const QRegExp& exp, QTreeWidgetItem* item) const
+bool KMyMoneyAccountSelector::match(const QRegularExpression& exp, QTreeWidgetItem* item) const
 {
     if (!item->flags().testFlag(Qt::ItemIsSelectable))
         return false;
-    return exp.indexIn(item->data(0, (int)eWidgets::Selector::Role::Key).toString().mid(1)) != -1;
+    const auto matchingItem(exp.match(item->data(0, static_cast<int>(eWidgets::Selector::Role::Key)).toString().mid(1)));
+    return matchingItem.hasMatch();
 }
 
 bool KMyMoneyAccountSelector::contains(const QString& txt) const
@@ -192,8 +193,9 @@ bool KMyMoneyAccountSelector::contains(const QString& txt) const
                        i18n("Security");
 
     while ((it_v = *it) != 0) {
-        QRegExp exp(QString("^(?:%1):%2$").arg(baseName).arg(QRegExp::escape(txt)));
-        if (exp.indexIn(it_v->data(0, (int)eWidgets::Selector::Role::Key).toString().mid(1)) != -1) {
+        const QRegularExpression exp(QString("^(?:%1):%2$").arg(baseName).arg(QRegularExpression::escape(txt)));
+        const auto matchingItem(exp.match(it_v->data(0, static_cast<int>(eWidgets::Selector::Role::Key)).toString().mid(1)));
+        if (matchingItem.hasMatch()) {
             return true;
         }
         it++;
diff --git a/kmymoney/widgets/kmymoneyaccountselector.h b/kmymoney/widgets/kmymoneyaccountselector.h
index 3c669255f..9fdf6e442 100644
--- a/kmymoney/widgets/kmymoneyaccountselector.h
+++ b/kmymoney/widgets/kmymoneyaccountselector.h
@@ -83,7 +83,7 @@ public:
       * @retval true item matches
       * @retval false item does not match
       */
-    virtual bool match(const QRegExp& exp, QTreeWidgetItem* item) const override;
+    virtual bool match(const QRegularExpression& exp, QTreeWidgetItem* item) const override;
 
     /**
       * This method returns, if any of the items in the selector contains
diff --git a/kmymoney/widgets/kmymoneycalculator.cpp b/kmymoney/widgets/kmymoneycalculator.cpp
index 6813b9124..acd93b5a6 100644
--- a/kmymoney/widgets/kmymoneycalculator.cpp
+++ b/kmymoney/widgets/kmymoneycalculator.cpp
@@ -17,7 +17,7 @@
 #include <QLabel>
 #include <QLocale>
 #include <QPushButton>
-#include <QRegExp>
+#include <QRegularExpression>
 #include <QSignalMapper>
 
 // ----------------------------------------------------------------------------
@@ -55,7 +55,7 @@ public:
     void changeDisplay(const QString& str)
     {
         auto txt = str;
-        txt.replace(QRegExp("\\."), m_comma);
+        txt.replace(QRegularExpression(QLatin1String("\\.")), m_comma);
         display->setText("<b>" + txt + "</b>");
     }
 
@@ -429,7 +429,7 @@ QString KMyMoneyCalculator::result() const
 {
     Q_D(const KMyMoneyCalculator);
     auto txt = d->m_result;
-    txt.replace(QRegExp("\\."), d->m_comma);
+    txt.replace(QRegularExpression(QLatin1String("\\.")), d->m_comma);
     if (txt[0] == '-') {
         txt = txt.mid(1); // get rid of the minus sign
         QString mask;
@@ -564,9 +564,9 @@ void KMyMoneyCalculator::setInitialValues(const QString& value, QKeyEvent* ev)
     // setup operand
     d->operand = value;
     // make sure the group/thousands separator is removed ...
-    d->operand.replace(QRegExp(QString("\\%1").arg(QLocale().groupSeparator())), QChar());
+    d->operand.replace(QRegularExpression(QStringLiteral("\\%1").arg(QLocale().groupSeparator())), QChar());
     // ... and the decimal is represented by a dot
-    d->operand.replace(QRegExp(QString("\\%1").arg(d->m_comma)), QChar('.'));
+    d->operand.replace(QRegularExpression(QStringLiteral("\\%1").arg(d->m_comma)), QChar('.'));
     if (d->operand.contains('(')) {
         negative = true;
         d->operand.remove('(');
diff --git a/kmymoney/widgets/kmymoneycompletion_p.h b/kmymoney/widgets/kmymoneycompletion_p.h
index 2e0c7b3e3..920e4ec09 100644
--- a/kmymoney/widgets/kmymoneycompletion_p.h
+++ b/kmymoney/widgets/kmymoneycompletion_p.h
@@ -10,7 +10,7 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QRegExp>
+#include <QRegularExpression>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -40,7 +40,7 @@ public:
     QString                     m_id;
     QTreeWidget*                m_lv;
     KMyMoneySelector*           m_selector;
-    QRegExp                     m_lastCompletion;
+    QRegularExpression m_lastCompletion;
     static const int MAX_ITEMS = 16;
 };
 
diff --git a/kmymoney/widgets/kmymoneyselector.cpp b/kmymoney/widgets/kmymoneyselector.cpp
index 8d3c6b2b2..da583c69f 100644
--- a/kmymoney/widgets/kmymoneyselector.cpp
+++ b/kmymoney/widgets/kmymoneyselector.cpp
@@ -9,9 +9,9 @@
 // ----------------------------------------------------------------------------
 // QT Includes
 
-#include <QStyle>
-#include <QRegExp>
 #include <QApplication>
+#include <QRegularExpression>
+#include <QStyle>
 
 // ----------------------------------------------------------------------------
 // KDE Includes
@@ -396,30 +396,29 @@ QTreeWidget* KMyMoneySelector::listView() const
 
 int KMyMoneySelector::slotMakeCompletion(const QString& _txt)
 {
-    QString txt(QRegExp::escape(_txt));
+    QString txt(QRegularExpression::escape(_txt));
     if (KMyMoneySettings::stringMatchFromStart() && QLatin1String(this->metaObject()->className()) == QLatin1String("KMyMoneySelector"))
         txt.prepend('^');
-    return slotMakeCompletion(QRegExp(txt, Qt::CaseInsensitive));
+    return slotMakeCompletion(QRegularExpression(txt, QRegularExpression::CaseInsensitiveOption));
 }
 
-bool KMyMoneySelector::match(const QRegExp& exp, QTreeWidgetItem* item) const
+bool KMyMoneySelector::match(const QRegularExpression& exp, QTreeWidgetItem* item) const
 {
-    return exp.indexIn(item->text(0)) != -1;
+    return exp.match(item->text(0)).hasMatch();
 }
 
-int KMyMoneySelector::slotMakeCompletion(const QRegExp& _exp)
+int KMyMoneySelector::slotMakeCompletion(const QRegularExpression& _exp)
 {
     Q_D(KMyMoneySelector);
     auto exp(_exp);
-    QString pattern = exp.pattern();
-    if (exp.patternSyntax() == QRegExp::RegExp) {
-        auto replacement = QStringLiteral(".*:");
-        if (!KMyMoneySettings::stringMatchFromStart() || QLatin1String(this->metaObject()->className()) != QLatin1String("KMyMoneySelector")) {
-            replacement.append(QLatin1String(".*"));
-        }
-        pattern.replace(QLatin1String(":"), replacement);
-        exp.setPattern(pattern);
+    auto pattern = exp.pattern();
+    auto replacement = QStringLiteral(".*:");
+    if (!KMyMoneySettings::stringMatchFromStart() || QLatin1String(this->metaObject()->className()) != QLatin1String("KMyMoneySelector")) {
+        replacement.append(QLatin1String(".*"));
     }
+    pattern.replace(QLatin1String(":"), replacement);
+    exp.setPattern(pattern);
+
     QTreeWidgetItemIterator it(d->m_treeWidget, QTreeWidgetItemIterator::Selectable);
 
     QTreeWidgetItem* it_v;
diff --git a/kmymoney/widgets/kmymoneyselector.h b/kmymoney/widgets/kmymoneyselector.h
index 1663fd0ed..84c36058f 100644
--- a/kmymoney/widgets/kmymoneyselector.h
+++ b/kmymoney/widgets/kmymoneyselector.h
@@ -227,7 +227,7 @@ public:
       * @retval true item matches
       * @retval false item does not match
       */
-    virtual bool match(const QRegExp& exp, QTreeWidgetItem* item) const;
+    virtual bool match(const QRegularExpression& exp, QTreeWidgetItem* item) const;
 
     /**
       * This method returns a pointer to the QListViewItem with the id @a id.
@@ -310,20 +310,20 @@ protected:
 
 public Q_SLOTS:
     /**
-      * Hide all listview items that do not match the regular expression @a exp.
-      * This method returns the number of visible items
-      *
-      * @param exp const reference to QRegExp that an item must match to stay visible
-      *
-      * @return number of visible items
-      */
-    int slotMakeCompletion(const QRegExp& exp);
+     * Hide all listview items that do not match the regular expression @a exp.
+     * This method returns the number of visible items
+     *
+     * @param exp const reference to QRegularExpression that an item must match to stay visible
+     *
+     * @return number of visible items
+     */
+    int slotMakeCompletion(const QRegularExpression& exp);
 
     /**
-      * This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
-      *
-      * @param txt contains the pattern for a QRegExp
-      */
+     * This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
+     *
+     * @param txt contains the pattern for a QRegularExpression
+     */
     int slotMakeCompletion(const QString& txt);
 
 
diff --git a/tools/xea2kmt.cpp b/tools/xea2kmt.cpp
index c620b48c1..3f8da246b 100644
--- a/tools/xea2kmt.cpp
+++ b/tools/xea2kmt.cpp
@@ -5,13 +5,14 @@
 
 #include "../kmymoney/mymoney/mymoneyaccount.h"
 
+#include <QDebug>
 #include <QDir>
 #include <QFile>
-#include <QStringList>
 #include <QMap>
+#include <QRegularExpression>
+#include <QStringList>
 #include <QTextStream>
 #include <QXmlStreamReader>
-#include <QDebug>
 
 #include "mymoneyenums.h"
 
@@ -478,7 +479,7 @@ protected:
         xml.writeStartDocument();
 
         QString fileName = inFileName;
-        fileName.replace(QRegExp(".*/accounts"),"accounts");
+        fileName.replace(QRegularExpression(".*/accounts"), "accounts");
         xml.writeComment(QString("\n"
                                  "     Converted using xea2kmt from GnuCash sources\n"
                                  "\n"


More information about the kde-doc-english mailing list