Skip to content

Commit

Permalink
Fix QRegularExpressionMatch capture-related documentation
Browse files Browse the repository at this point in the history
The documentation is not explicit enough about the content of the
returned list of capturedList nor the element 0 when calling captured or
its friends.

The first element (aka element 0) is the whole string captured when one
or more groups are used.

Change-Id: I3c59ebfc9f6d762dd4d8aaf8f5c0de24359f53d7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
  • Loading branch information
sgaist committed Dec 15, 2018
1 parent 649ee12 commit 41c1866
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/corelib/tools/qregularexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,9 @@ int QRegularExpressionMatch::lastCapturedIndex() const
If the \a nth capturing group did not capture a string, or if there is no
such capturing group, returns a null QString.
\note The implicit capturing group number 0 captures the substring matched
by the entire pattern.
\sa capturedRef(), capturedView(), lastCapturedIndex(), capturedStart(), capturedEnd(),
capturedLength(), QString::isNull()
*/
Expand All @@ -2160,6 +2163,9 @@ QString QRegularExpressionMatch::captured(int nth) const
If the \a nth capturing group did not capture a string, or if there is no
such capturing group, returns a null QStringRef.
\note The implicit capturing group number 0 captures the substring matched
by the entire pattern.
\sa captured(), capturedView(), lastCapturedIndex(), capturedStart(), capturedEnd(),
capturedLength(), QStringRef::isNull()
*/
Expand All @@ -2184,6 +2190,9 @@ QStringRef QRegularExpressionMatch::capturedRef(int nth) const
If the \a nth capturing group did not capture a string, or if there is no
such capturing group, returns a null QStringView.
\note The implicit capturing group number 0 captures the substring matched
by the entire pattern.
\sa captured(), capturedRef(), lastCapturedIndex(), capturedStart(), capturedEnd(),
capturedLength(), QStringView::isNull()
*/
Expand Down Expand Up @@ -2296,7 +2305,9 @@ QStringView QRegularExpressionMatch::capturedView(QStringView name) const

/*!
Returns a list of all strings captured by capturing groups, in the order
the groups themselves appear in the pattern string.
the groups themselves appear in the pattern string. The list includes the
implicit capturing group number 0, capturing the substring matched by the
entire pattern.
*/
QStringList QRegularExpressionMatch::capturedTexts() const
{
Expand Down

0 comments on commit 41c1866

Please sign in to comment.