Use static QRegularExpression

This commit is contained in:
Jonas Kvinge
2024-08-24 17:23:10 +02:00
parent a2cae06582
commit bc667a6474
31 changed files with 121 additions and 67 deletions

View File

@@ -62,9 +62,12 @@ QUrl LyricFindLyricsProvider::Url(const LyricsSearchRequest &request) {
QString LyricFindLyricsProvider::StringFixup(const QString &text) {
static const QRegularExpression regex_illegal_characters(QStringLiteral("[^\\w0-9_\\- ]"));
static const QRegularExpression regex_multiple_whitespaces(QStringLiteral(" {2,}"));
return Utilities::Transliterate(text)
.remove(QRegularExpression(QStringLiteral("[^\\w0-9_\\- ]")))
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
.remove(regex_illegal_characters)
.replace(regex_multiple_whitespaces, QStringLiteral(" "))
.simplified()
.replace(QLatin1Char(' '), QLatin1Char('-'))
.toLower();