QRegularExpressionMatchIterator¶
The
QRegularExpressionMatchIteratorclass provides an iterator on the results of a global match of aQRegularExpressionobject against a string. More…

Synopsis¶
Functions¶
def
hasNext()def
isValid()def
matchOptions()def
matchType()def
next()def
peekNext()def
regularExpression()def
swap(other)
Detailed Description¶
A
QRegularExpressionMatchIteratorobject is a forward only Java-like iterator; it can be obtained by calling theglobalMatch()function. A newQRegularExpressionMatchIteratorwill be positioned before the first result. You can then call thehasNext()function to check if there are more results available; if so, thenext()function will return the next result and advance the iterator.Each result is a
QRegularExpressionMatchobject holding all the information for that result (including captured substrings).For instance:
// extracts the words QRegularExpression re("(\\w+)"); QString subject("the quick fox"); QRegularExpressionMatchIterator i = re.globalMatch(subject); while (i.hasNext()) { QRegularExpressionMatch match = i.next(); // ... }Moreover,
QRegularExpressionMatchIteratoroffers apeekNext()function to get the next result without advancing the iterator.You can retrieve the
QRegularExpressionobject the subject string was matched against by calling theregularExpression()function; the match type and the match options are available as well by calling thematchType()and thematchOptions()respectively.Please refer to the
QRegularExpressiondocumentation for more information about the Qt regular expression classes.
- class PySide2.QtCore.QRegularExpressionMatchIterator¶
PySide2.QtCore.QRegularExpressionMatchIterator(iterator)
- param iterator:
Constructs an empty, valid
QRegularExpressionMatchIteratorobject. The regular expression is set to a default-constructed one; the match type toNoMatchand the match options toNoMatchOption.Invoking the
hasNext()member function on the constructed object will return false, as the iterator is not iterating on a valid sequence of matches.Constructs a
QRegularExpressionMatchIteratorobject as a copy ofiterator.See also
operator=()
- PySide2.QtCore.QRegularExpressionMatchIterator.hasNext()¶
- Return type:
bool
Returns
trueif there is at least one match result ahead of the iterator; otherwise it returnsfalse.See also
- PySide2.QtCore.QRegularExpressionMatchIterator.isValid()¶
- Return type:
bool
Returns
trueif the iterator object was obtained as a result from theglobalMatch()function invoked on a validQRegularExpressionobject; returnsfalseif theQRegularExpressionwas invalid.See also
- PySide2.QtCore.QRegularExpressionMatchIterator.matchOptions()¶
- Return type:
MatchOptions
Returns the match options that were used to get this
QRegularExpressionMatchIteratorobject, that is, the match options that were passed toglobalMatch().See also
- PySide2.QtCore.QRegularExpressionMatchIterator.matchType()¶
- Return type:
Returns the match type that was used to get this
QRegularExpressionMatchIteratorobject, that is, the match type that was passed toglobalMatch().
- PySide2.QtCore.QRegularExpressionMatchIterator.next()¶
- Return type:
Returns the next match result and advances the iterator by one position.
Note
Calling this function when the iterator is at the end of the result set leads to undefined results.
- PySide2.QtCore.QRegularExpressionMatchIterator.peekNext()¶
- Return type:
Returns the next match result without moving the iterator.
Note
Calling this function when the iterator is at the end of the result set leads to undefined results.
- PySide2.QtCore.QRegularExpressionMatchIterator.regularExpression()¶
- Return type:
Returns the
QRegularExpressionobject whose globalMatch() function returned this object.See also
- PySide2.QtCore.QRegularExpressionMatchIterator.swap(other)¶
- Parameters:
Swaps the iterator
otherwith this iterator object. This operation is very fast and never fails.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.