diff options
author | Giuseppe D'Angelo <dangelog@gmail.com> | 2012-02-19 23:56:50 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-06 23:56:14 +0100 |
commit | efcd4d9470781e3a0331afeab49cd00cee24399f (patch) | |
tree | 00d8da81efb63985afb3513491e357e213e776dd /src/corelib/tools/qregularexpression.cpp | |
parent | 1899861858eb262df7826eb32d1274233a35536e (diff) |
QRegularExpression: add captureCount()
QRegularExpression::captureCount() returns the number of
capturing groups inside the regular expression pattern.
Change-Id: Ib90ce67c67d06ab2966f0c98bd91da21defc156d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qregularexpression.cpp')
-rw-r--r-- | src/corelib/tools/qregularexpression.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 17988bdb31..7bbac0144b 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -1341,6 +1341,19 @@ void QRegularExpression::setPatternOptions(PatternOptions options) } /*! + Returns the number of capturing groups inside the pattern string, + or -1 if the regular expression is not valid. + + \sa isValid() +*/ +int QRegularExpression::captureCount() const +{ + if (!isValid()) // will compile the pattern + return -1; + return d->capturingCount; +} + +/*! Returns true if the regular expression is a valid regular expression (that is, it contains no syntax errors, etc.), or false otherwise. Use errorString() to obtain a textual description of the error. |