diff options
Diffstat (limited to 'src/corelib/text')
-rw-r--r-- | src/corelib/text/qregularexpression.cpp | 19 | ||||
-rw-r--r-- | src/corelib/text/qregularexpression.h | 3 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index 6b81f5cc79..25e2169b06 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -1935,6 +1935,25 @@ QString QRegularExpression::wildcardToRegularExpression(QStringView pattern, Wil return rx; } +/*! + \since 6.0 + Returns a regular expression of the glob pattern \a pattern. + + Equivalent to + \code + auto reOptions = cs == Qt::CaseSensitive ? QRegularExpression::NoPatternOption : + QRegularExpression::CaseInsensitiveOption; + return QRegularExpression(wildcardToRegularExpression(str, options), reOptions); + \endcode +*/ +QRegularExpression QRegularExpression::fromWildcard(QStringView str, Qt::CaseSensitivity cs, + WildcardConversionOptions options) +{ + auto reOptions = cs == Qt::CaseSensitive ? QRegularExpression::NoPatternOption : + QRegularExpression::CaseInsensitiveOption; + return QRegularExpression(wildcardToRegularExpression(str, options), reOptions); +} + #if QT_STRINGVIEW_LEVEL < 2 /*! \fn QRegularExpression::anchoredPattern(const QString &expression) diff --git a/src/corelib/text/qregularexpression.h b/src/corelib/text/qregularexpression.h index cfb7f34d9d..10ff2e94cb 100644 --- a/src/corelib/text/qregularexpression.h +++ b/src/corelib/text/qregularexpression.h @@ -165,6 +165,9 @@ public: static QString wildcardToRegularExpression(QStringView str, WildcardConversionOptions options = DefaultWildcardConversion); static QString anchoredPattern(QStringView expression); + static QRegularExpression fromWildcard(QStringView str, Qt::CaseSensitivity cs = Qt::CaseInsensitive, + WildcardConversionOptions options = DefaultWildcardConversion); + bool operator==(const QRegularExpression &re) const; inline bool operator!=(const QRegularExpression &re) const { return !operator==(re); } |