QRegularExpressionMatchIteratorclass provides an iterator on the results of a global match of aQRegularExpression对象与字符串。 更多 …
def
hasNext
()
def
isValid
()
def
matchOptions
()
def
matchType
()
def
next
()
def
peekNext
()
def
regularExpression
()
def
swap
(other)
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.每个结果是
QRegularExpressionMatch对象,保持结果的所有信息 (包括捕获子字符串)。例如:
// 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.可以检索
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()和matchOptions()分别。请参考
QRegularExpression文档编制,了解有关 Qt 正则表达式类的更多信息。
QRegularExpressionMatchIterator
¶
QRegularExpressionMatchIterator(iterator)
- param iterator
Constructs an empty, valid
QRegularExpressionMatchIterator
object. The regular expression is set to a default-constructed one; the match type to
NoMatch
and the match options to
NoMatchOption
.
援引
hasNext()
member function on the constructed object will return false, as the iterator is not iterating on a valid sequence of matches.
构造
QRegularExpressionMatchIterator
object as a copy of
iterator
.
另请参阅
operator=()
PySide2.QtCore.QRegularExpressionMatchIterator.
hasNext
(
)
¶
bool
返回
true
if there is at least one match result ahead of the iterator; otherwise it returns
false
.
另请参阅
PySide2.QtCore.QRegularExpressionMatchIterator.
isValid
(
)
¶
bool
返回
true
if the iterator object was obtained as a result from the
globalMatch()
function invoked on a valid
QRegularExpression
对象;返回
false
若
QRegularExpression
was invalid.
另请参阅
PySide2.QtCore.QRegularExpressionMatchIterator.
matchOptions
(
)
¶
MatchOptions
Returns the match options that were used to get this
QRegularExpressionMatchIterator
object, that is, the match options that were passed to
globalMatch()
.
PySide2.QtCore.QRegularExpressionMatchIterator.
matchType
(
)
¶
MatchType
Returns the match type that was used to get this
QRegularExpressionMatchIterator
object, that is, the match type that was passed to
globalMatch()
.
PySide2.QtCore.QRegularExpressionMatchIterator.
next
(
)
¶
Returns the next match result and advances the iterator by one position.
注意
Calling this function when the iterator is at the end of the result set leads to undefined results.
PySide2.QtCore.QRegularExpressionMatchIterator.
peekNext
(
)
¶
Returns the next match result without moving the iterator.
注意
Calling this function when the iterator is at the end of the result set leads to undefined results.
PySide2.QtCore.QRegularExpressionMatchIterator.
regularExpression
(
)
¶
返回
QRegularExpression
object whose globalMatch() function returned this object.
PySide2.QtCore.QRegularExpressionMatchIterator.
swap
(
other
)
¶
other
–
QRegularExpressionMatchIterator
Swaps the iterator
other
with this iterator object. This operation is very fast and never fails.