mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #710 Simple algorithms to replace several regular expressions.
This commit is contained in:
@@ -301,13 +301,8 @@ namespace BlackMisc
|
||||
QString CAirlineIcaoCode::normalizeDesignator(const QString candidate)
|
||||
{
|
||||
QString n(candidate.trimmed().toUpper());
|
||||
if (n.contains(' ')) { n = n.left(n.indexOf(' ')); } // cutoff at first space
|
||||
if (n.isEmpty()) { return n; }
|
||||
|
||||
static QThreadStorage<QRegularExpression> tsRegex;
|
||||
if (! tsRegex.hasLocalData()) { tsRegex.setLocalData(QRegularExpression("[^a-zA-Z\\d\\s]")); }
|
||||
const QRegularExpression ®exp = tsRegex.localData();
|
||||
return n.remove(regexp);
|
||||
n = n.left(indexOfChar(n, [](QChar c) { return c.isSpace(); }));
|
||||
return removeChars(n, [](QChar c) { return !c.isLetterOrNumber(); });
|
||||
}
|
||||
|
||||
QString CAirlineIcaoCode::getCombinedStringWithKey() const
|
||||
|
||||
Reference in New Issue
Block a user