Member Function Documentation
QRegularExpressionMatch::QRegularExpressionMatch(const QRegularExpressionMatch & match)
Constructs a match result by copying the result of the given match.
See also operator=().
QRegularExpressionMatch::~QRegularExpressionMatch()
Destroys the match result.
QString QRegularExpressionMatch::captured(int nth = 0) const
Returns the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QString.
See also capturedRef(), lastCapturedIndex(), capturedStart(), capturedEnd(), capturedLength(), and QString::isNull().
QString QRegularExpressionMatch::captured(const QString & name) const
Returns the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns a null QString.
See also capturedRef(), capturedStart(), capturedEnd(), capturedLength(), and QString::isNull().
int QRegularExpressionMatch::capturedEnd(int nth = 0) const
Returns the offset inside the subject string immediately after the ending position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.
See also capturedStart(), capturedLength(), and captured().
int QRegularExpressionMatch::capturedEnd(const QString & name) const
Returns the offset inside the subject string immediately after the ending position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.
See also capturedStart(), capturedLength(), and captured().
int QRegularExpressionMatch::capturedLength(int nth = 0) const
Returns the length of the substring captured by the nth capturing group.
Note: This function returns 0 if the nth capturing group did not capture a string or doesn't exist.
See also capturedStart(), capturedEnd(), and captured().
int QRegularExpressionMatch::capturedLength(const QString & name) const
Returns the offset inside the subject string corresponding to the starting position of the substring captured by the capturing group named name.
Note: This function returns 0 if the capturing group named name did not capture a string or doesn't exist.
See also capturedStart(), capturedEnd(), and captured().
QStringRef QRegularExpressionMatch::capturedRef(int nth = 0) const
Returns a reference to the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns a null QStringRef.
See also captured(), lastCapturedIndex(), capturedStart(), capturedEnd(), capturedLength(), and QStringRef::isNull().
QStringRef QRegularExpressionMatch::capturedRef(const QString & name) const
Returns a reference to the string captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns a null QStringRef.
See also captured(), capturedStart(), capturedEnd(), capturedLength(), and QStringRef::isNull().
int QRegularExpressionMatch::capturedStart(int nth = 0) const
Returns the offset inside the subject string corresponding to the starting position of the substring captured by the nth capturing group. If the nth capturing group did not capture a string or doesn't exist, returns -1.
See also capturedEnd(), capturedLength(), and captured().
int QRegularExpressionMatch::capturedStart(const QString & name) const
Returns the offset inside the subject string corresponding to the starting position of the substring captured by the capturing group named name. If the capturing group named name did not capture a string or doesn't exist, returns -1.
See also capturedEnd(), capturedLength(), and captured().
QStringList QRegularExpressionMatch::capturedTexts() const
Returns a list of all strings captured by capturing groups, in the order the groups themselves appear in the pattern string.
bool QRegularExpressionMatch::hasMatch() const
Returns true if the regular expression matched against the subject string, or false otherwise.
See also QRegularExpression::match() and hasPartialMatch().
bool QRegularExpressionMatch::hasPartialMatch() const
Returns true if the regular expression partially matched against the subject string, or false otherwise.
Note: Only a match that explicitely used the one of the partial match types can yield a partial match. Still, if such a match succeeds totally, this function will return false, while hasMatch() will return true.
See also QRegularExpression::match(), QRegularExpression::MatchType, and hasMatch().
bool QRegularExpressionMatch::isValid() const
Returns true if the match object was obtained as a result from the QRegularExpression::match() function invoked on a valid QRegularExpression object; returns false if the QRegularExpression was invalid.
See also QRegularExpression::match() and QRegularExpression::isValid().
int QRegularExpressionMatch::lastCapturedIndex() const
Returns the index of the last capturing group that captured something, including the implicit capturing group 0. This can be used to extract all the substrings that were captured:
QRegularExpressionMatch match = re.match(...);
for (int i = 0; i <= match.lastCapturedIndex(); ++i) {
QString captured = match.captured(i);
}
Note that some of the capturing groups with an index less than lastCapturedIndex() could have not matched, and therefore captured nothing.
If the regular expression did not match, this function returns -1.
See also captured(), capturedStart(), capturedEnd(), and capturedLength().
Returns the match options that were used to get this QRegularExpressionMatch object, that is, the match options that were passed to QRegularExpression::match() or QRegularExpression::globalMatch().
See also QRegularExpression::match(), regularExpression(), and matchType().
Returns the match type that was used to get this QRegularExpressionMatch object, that is, the match type that was passed to QRegularExpression::match() or QRegularExpression::globalMatch().
See also QRegularExpression::match(), regularExpression(), and matchOptions().
QRegularExpression QRegularExpressionMatch::regularExpression() const
Returns the QRegularExpression object whose match() function returned this object.
See also QRegularExpression::match(), matchType(), and matchOptions().
void QRegularExpressionMatch::swap(QRegularExpressionMatch & other)
Swaps the match result other with this match result. This operation is very fast and never fails.
QRegularExpressionMatch & QRegularExpressionMatch::operator=(const QRegularExpressionMatch & match)
Assigns the match result match to this object, and returns a reference to the copy.