diff options
author | Samuel Gaist <samuel.gaist@idiap.ch> | 2018-07-25 09:23:28 +0200 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@idiap.ch> | 2018-08-19 11:38:26 +0000 |
commit | bcd80eebf983a2b547662d7e0d67bc8624d1130f (patch) | |
tree | 248e569a21dc62ec8f2016c5efdde6d6afcf1e02 /src/corelib/tools/qregularexpression.cpp | |
parent | 6228c0528ca5cea2f8c309c4f64e38eb729b04da (diff) |
Implement exact match expression builder for QRegularExpression
QRegularExpression doesn't offer a direct equivalent of QRegExp's exact
match.
There are several places in the Qt sources that use this feature. This
patch implements a small helper function that builds the expression as
recommended in the documentation and updates the related code.
[ChangeLog][Core][Tools] QRegularExpression now provides
anchoredPattern() which is a helper function to build regular
expressions used for exact matching.
Change-Id: Idbbf142c4c5cb9b62abf8229f4ce85fd4409e5d0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qregularexpression.cpp')
-rw-r--r-- | src/corelib/tools/qregularexpression.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 1bd06a73cd..6f0e572f41 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -483,6 +483,11 @@ QT_BEGIN_NAMESPACE Note the usage of the non-capturing group in order to preserve the meaning of the branch operator inside the pattern. + The QRegularExpression::anchoredPattern() helper method does exactly that for + you. + + \sa anchoredPattern + \section3 Porting from QRegExp's Partial Matching When using QRegExp::exactMatch(), if an exact match was not found, one @@ -1995,6 +2000,17 @@ QString QRegularExpression::wildcardToRegularExpression(const QString &pattern) } /*! + \fn QRegularExpression::anchoredPattern(const QString &expression) + + \since 5.12 + + Returns the expression wrapped between the \c{\A} and \c{\z} anchors to be + used for exact matching. + + \sa {Porting from QRegExp's Exact Matching} +*/ + +/*! \since 5.1 Constructs a valid, empty QRegularExpressionMatch object. The regular |