|
|
|
@ -32,11 +32,12 @@
@@ -32,11 +32,12 @@
|
|
|
|
|
#include <cmath> |
|
|
|
|
|
|
|
|
|
#include <QLocale> |
|
|
|
|
#include <QRegularExpression> |
|
|
|
|
#include <QStringList> |
|
|
|
|
#include <QVector> |
|
|
|
|
|
|
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) |
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) |
|
|
|
|
#include <QRegularExpression> |
|
|
|
|
#else |
|
|
|
|
#include <QRegExp> |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
@ -56,11 +57,7 @@ QString Utils::String::fromDouble(const double n, const int precision)
@@ -56,11 +57,7 @@ QString Utils::String::fromDouble(const double n, const int precision)
|
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) |
|
|
|
|
QString Utils::String::wildcardToRegexPattern(const QString &pattern) |
|
|
|
|
{ |
|
|
|
|
// replace [ and ] with [[] and []], respectively
|
|
|
|
|
QString escapedPattern = pattern; |
|
|
|
|
escapedPattern.replace(QRegularExpression(u"\\[|\\]"_qs), u"[\\0]"_qs); |
|
|
|
|
|
|
|
|
|
return QRegularExpression::wildcardToRegularExpression(escapedPattern, QRegularExpression::UnanchoredWildcardConversion); |
|
|
|
|
return QRegularExpression::wildcardToRegularExpression(pattern, QRegularExpression::UnanchoredWildcardConversion); |
|
|
|
|
} |
|
|
|
|
#else |
|
|
|
|
// This is marked as internal in QRegExp.cpp, but is exported. The alternative would be to
|
|
|
|
@ -69,11 +66,7 @@ QString qt_regexp_toCanonical(const QString &pattern, QRegExp::PatternSyntax pat
@@ -69,11 +66,7 @@ QString qt_regexp_toCanonical(const QString &pattern, QRegExp::PatternSyntax pat
|
|
|
|
|
|
|
|
|
|
QString Utils::String::wildcardToRegexPattern(const QString &pattern) |
|
|
|
|
{ |
|
|
|
|
// replace [ and ] with [[] and []], respectively
|
|
|
|
|
QString escapedPattern = pattern; |
|
|
|
|
escapedPattern.replace(QRegularExpression(u"\\[|\\]"_qs), u"[\\0]"_qs); |
|
|
|
|
|
|
|
|
|
return qt_regexp_toCanonical(escapedPattern, QRegExp::Wildcard); |
|
|
|
|
return qt_regexp_toCanonical(pattern, QRegExp::Wildcard); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|