The QRegularExpressionMatchIterator class provides an iterator on the results of a global match of a QRegularExpression 对象与字符串。 更多...
头: | #include <QRegularExpressionMatchIterator> |
qmake: | QT += core |
Since: | Qt 5.0 |
注意: 此类的所有函数 可重入 .
QRegularExpressionMatchIterator () | |
QRegularExpressionMatchIterator (const QRegularExpressionMatchIterator & iterator ) | |
~QRegularExpressionMatchIterator () | |
bool | hasNext () const |
bool | isValid () const |
QRegularExpression::MatchOptions | matchOptions () const |
QRegularExpression::MatchType | matchType () const |
QRegularExpressionMatch | next () |
QRegularExpressionMatch | peekNext () const |
QRegularExpression | regularExpression () const |
void | swap (QRegularExpressionMatchIterator & other ) |
QRegularExpressionMatchIterator & | operator= (const QRegularExpressionMatchIterator & iterator ) |
QRegularExpressionMatchIterator & | operator= (QRegularExpressionMatchIterator && iterator ) |
The QRegularExpressionMatchIterator class provides an iterator on the results of a global match of a QRegularExpression 对象与字符串。
A QRegularExpressionMatchIterator object is a forward only Java-like iterator; it can be obtained by calling the QRegularExpression::globalMatch () function. A new QRegularExpressionMatchIterator will be positioned before the first result. You can then call the hasNext () function to check if there are more results available; if so, the next () 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, QRegularExpressionMatchIterator offers a peekNext () function to get the next result without advancing the iterator.
可以检索 QRegularExpression object the subject string was matched against by calling the regularExpression () function; the match type and the match options are available as well by calling the matchType () 和 matchOptions () 分别。
请参考 QRegularExpression 文档编制,了解有关 Qt 正则表达式类的更多信息。
另请参阅 QRegularExpression and QRegularExpressionMatch .
Constructs an empty, valid QRegularExpressionMatchIterator object. The regular expression is set to a default-constructed one; the match type to QRegularExpression::NoMatch and the match options to QRegularExpression::NoMatchOption .
援引 hasNext () member function on the constructed object will return false, as the iterator is not iterating on a valid sequence of matches.
该函数在 Qt 5.1 引入。
构造 QRegularExpressionMatchIterator object as a copy of iterator .
另请参阅 operator= ().
销毁 QRegularExpressionMatchIterator 对象。
返回
true
if there is at least one match result ahead of the iterator; otherwise it returns
false
.
另请参阅 next ().
返回
true
if the iterator object was obtained as a result from the
QRegularExpression::globalMatch
() function invoked on a valid
QRegularExpression
对象;返回
false
若
QRegularExpression
was invalid.
另请参阅 QRegularExpression::globalMatch () 和 QRegularExpression::isValid ().
Returns the match options that were used to get this QRegularExpressionMatchIterator object, that is, the match options that were passed to QRegularExpression::globalMatch ().
另请参阅 QRegularExpression::globalMatch (), regularExpression (),和 matchType ().
Returns the match type that was used to get this QRegularExpressionMatchIterator object, that is, the match type that was passed to QRegularExpression::globalMatch ().
另请参阅 QRegularExpression::globalMatch (), regularExpression (),和 matchOptions ().
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.
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.
返回 QRegularExpression 对象,globalMatch() 函数会返回此对象。
另请参阅 QRegularExpression::globalMatch (), matchType (),和 matchOptions ().
交换迭代器 other with this iterator object. This operation is very fast and never fails.
赋值迭代器 iterator to this object, and returns a reference to the copy.
Move-assigns the iterator 到此对象。