refs #710 Simple algorithms to replace several regular expressions.

This commit is contained in:
Mathew Sutcliffe
2016-08-30 04:02:00 +01:00
parent d2aa2e9c1c
commit 87eeac4e15
13 changed files with 218 additions and 57 deletions

View File

@@ -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 &regexp = 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