Replace QRegExp with QRegularExpression

Reviewers: kbasan, msutcliffe

Reviewed By: kbasan, msutcliffe

Subscribers: jenkins

Differential Revision: https://dev.swift-project.org/D11
This commit is contained in:
Mathew Sutcliffe
2017-05-05 22:35:25 +01:00
parent 94fbfeefdb
commit d5ab73e1bc
17 changed files with 55 additions and 54 deletions

View File

@@ -10,7 +10,6 @@
#include "blackmisc/aviation/callsign.h"
#include "blackmisc/compare.h"
#include <QRegExp>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QStringList>
@@ -126,10 +125,10 @@ namespace BlackMisc
if (this->m_callsign.length() < 3) { return ""; }
if (this->isAtcCallsign()) { return ""; }
static const QRegExp regExp("^[A-Z]{3,}");
const int pos = regExp.indexIn(this->m_callsign);
if (pos < 0) { return ""; }
const QString airline = regExp.cap(0);
thread_local const QRegularExpression regExp("^[A-Z]{3,}");
QRegularExpressionMatch match = regExp.match(this->m_callsign);
if (!match.hasMatch()) { return QString(); }
const QString airline = match.captured(0);
if (airline.length() == 3) { return airline; } // we allow 3 letters
if (airline.length() == 4 && airline.startsWith('V')) { return airline; } // we allow virtual 4 letter codes, e.g. VDLD
return ""; // invalid