本文整理汇总了C++中QRegularExpressionMatchIterator::hasNext方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpressionMatchIterator::hasNext方法的具体用法?C++ QRegularExpressionMatchIterator::hasNext怎么用?C++ QRegularExpressionMatchIterator::hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegularExpressionMatchIterator
的用法示例。
在下文中一共展示了QRegularExpressionMatchIterator::hasNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLocalDefs
QStringList getLocalDefs(QString block, ConstRegExp REG_OUTER, const uint outerCapGroup,
ConstRegExp REG_INNER, const uint innerCapGroup,
ConstRegExp REMOVE_REG)
{
QStringList result;
QString params, currParam;
#ifdef DEBUG
qDebug() << "\n~~~~~~\n";
#endif
QRegularExpressionMatchIterator currMatchIter = REG_OUTER.globalMatch(block);
if (!currMatchIter.hasNext() )
return result; // empty result if not found
params = currMatchIter.next().captured(outerCapGroup);
currMatchIter = REG_INNER.globalMatch(params);
while (currMatchIter.hasNext() )
{
currParam = currMatchIter.next().captured(innerCapGroup).remove(REMOVE_REG).remove(WHITE_SPACES);
if (!currParam.isEmpty() )
result.append(currParam.split(",") );
}
#ifdef DEBUG
for (int resIter = 0; resIter < result.size(); ++resIter)
qDebug() << result.at(resIter).toLatin1().constData() << "\n";
#endif
return result;
} /* getLocalDefs */
示例2: re
/**
* @brief Returns a map of parsed markdown urls with their link texts as key
*
* @param text
* @return parsed urls
*/
QMap<QString, QString> QMarkdownTextEdit::parseMarkdownUrlsFromText( QString text )
{
QMap<QString, QString> urlMap;
// match urls like this: [this url](http://mylink)
QRegularExpression re("(\\[.*?\\]\\((.+?://.+?)\\))");
QRegularExpressionMatchIterator i = re.globalMatch( text );
while ( i.hasNext() )
{
QRegularExpressionMatch match = i.next();
QString linkText = match.captured(1);
QString url = match.captured(2);
urlMap[linkText] = url;
}
// match urls like this: <http://mylink>
re = QRegularExpression("(<(.+?://.+?)>)");
i = re.globalMatch( text );
while ( i.hasNext() )
{
QRegularExpressionMatch match = i.next();
QString linkText = match.captured(1);
QString url = match.captured(2);
urlMap[linkText] = url;
}
return urlMap;
}
示例3: re
SteamConfig::Element::Element(QList<QString> *lines) {
QString line;
QRegularExpression re("\"([^\"]*)\"");
QRegularExpressionMatchIterator i;
while (lines->length() > 0) {
line = lines->front();
lines->pop_front();
i = re.globalMatch(line);
if (i.hasNext())
break;
}
if (!lines->length()) // corrupt
return;
QRegularExpressionMatch match = i.next();
name = match.captured(1).toLower();
if (i.hasNext()) { // value is a string
match = i.next();
value = match.captured(1);
value.replace("\\\\", "\\");
}
line = lines->front();
if (line.contains("{")) {
lines->pop_front();
while (true) {
line = lines->front();
if (line.contains("}")) { // empty
lines->pop_front();
return;
}
Element e(lines);
children[e.name] = e;
}
}
}
示例4: Generate
// The actual generation engine
QString ShopTemplateManager::Generate(const Items &items) {
QString temp = shopTemplate;
{
QRegularExpression expr("{(?<key>.+?)(?<options>(\\|(.+?))*?)}");
QRegularExpressionMatchIterator matcher = expr.globalMatch(shopTemplate);
int offset = 0;
while (matcher.hasNext()) {
QRegularExpressionMatch match = matcher.next();
QString key = match.captured("key").toLower();
int startPos = offset + match.capturedStart();
int len = match.capturedLength();
QStringList optionsAndData = match.captured("options").split("|", QString::SkipEmptyParts);
QHash<QString, QString> options;
for (QString optionAndData : optionsAndData) {
int split = optionAndData.indexOf(":");
if (split == -1) {
options.insert(optionAndData.toLower(), "");
}
else {
QString option = optionAndData.left(split).toLower();
QString data = optionAndData.mid(split + 1);
options.insert(option, data);
}
}
QString replacement = FetchFromKey(key, items, &options);
temp.replace(startPos, len, replacement);
offset += replacement.length() - len;
}
}
// Now clean up empty spoiler tags!
int matches = -1;
while (matches != 0){
QRegularExpression expr("\\[spoiler=\\\"(?>.*?\\\"\\])(?>\\s*?\\[\\/spoiler\\]\\n)");
QRegularExpressionMatchIterator matcher = expr.globalMatch(temp);
int offset = 0;
matches = 0;
while (matcher.hasNext()) {
QRegularExpressionMatch match = matcher.next();
int startPos = match.capturedStart() + offset;
int length = match.capturedLength();
temp.remove(startPos, length);
offset -= length;
matches++;
}
}
return temp;
}
示例5: process
void FetchThread::process(QString phost)
{
QUdpSocket *udpSocket ;
udpSocket= new QUdpSocket(0);
udpSocket->bind(QHostAddress::LocalHost, 9999);
udpSocket->waitForConnected(250);
QTcpSocket socket;
socket.connectToHost("localhost", 4949);
socket.waitForConnected(500);
while (socket.waitForReadyRead(250));
QString t_hello = socket.readAll();
qDebug() << "READ: " << t_hello;
socket.write(QString("list\n").toStdString().c_str() );
while (socket.waitForReadyRead(250));
QString buf1 = socket.readAll();
qDebug() << "READ: " << buf1;
QStringList list_probe = buf1.split(QRegExp("\\s+"));
for (int z=0; z< list_probe.size(); z++)
{
QString probe=list_probe.at(z);
QString cmd = QString("fetch ").append(probe).append("\n");
qDebug() << "cmd : " << cmd;
socket.write(cmd.toStdString().c_str() );
while (socket.waitForReadyRead(250));
QString buf2 = socket.readAll();
qDebug() << "Rep fetch :" << buf2 << "\n";
QRegularExpression re("(\\w+).(\\w+) ([0-9.]+)\\n");
QRegularExpressionMatchIterator i = re.globalMatch(buf2);
re.setPatternOptions(QRegularExpression::MultilineOption);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
QString s_metric = match.captured(1);
QString s_value = match.captured(3);
QString s_mtr = "monit2influxdb,metric="+probe + "_" + s_metric + ",host=" + phost+ " value=" + s_value + " " + QString::number(1000000* QDateTime::currentMSecsSinceEpoch());
qDebug() << "metric: " << s_mtr.toLower();
udpSocket->writeDatagram(s_mtr.toStdString().c_str(), QHostAddress::LocalHost, 9999);
}
udpSocket->close();
}
}
示例6: createProposal
static void createProposal(QFutureInterface<QStringList> &future, const QString &text,
const QString &wordUnderCursor)
{
const QRegularExpression wordRE("([a-zA-Z_][a-zA-Z0-9_]{2,})");
QSet<QString> words;
QRegularExpressionMatchIterator it = wordRE.globalMatch(text);
int wordUnderCursorFound = 0;
while (it.hasNext()) {
if (future.isCanceled())
return;
QRegularExpressionMatch match = it.next();
const QString &word = match.captured();
if (word == wordUnderCursor) {
// Only add the word under cursor if it
// already appears elsewhere in the text
if (++wordUnderCursorFound < 2)
continue;
}
if (!words.contains(word))
words.insert(word);
}
future.reportResult(words.toList());
}
示例7: GetArenaCards
void WebUploader::GetArenaCards(QString &html)
{
//Ejemplo html
//<li><a href='#deck' data-toggle='tab'>Cards: List & Info</a></li>
if(html.contains("<li><a href='#deck' data-toggle='tab'>Cards: List & Info</a></li>"))
{
deckInWeb = true;
emit newWebDeckCardList();
qDebug() << "WebUploader: "<< "Inicio leer deck.";
//Ejemplo html carta
//<li id='374' class='list-group-item' data-name='1' data-cost='3' data-total='1' data-remaining='1' data-any='1'>
//<span style='display: inline-block;'>(3) <a href='http://www.hearthpwn.com/cards/428' onClick='return false;'>Acolyte of Pain</a>
//</span> (<span id='remaining-374' style='font-weight:bold;'>1</span> copy)</li>
QRegularExpression re(
"<li id='\\d+' class='list-group-item' data-name='\\d+' data-cost='\\d+' data-total='(\\d+)' data-remaining='\\d+' data-any='\\d+'>"
"<span style='display: inline-block;'>.*<a href=.*onClick=.*>(.+)</a> "
"</span>.*</li>");
QRegularExpressionMatchIterator reIterator = re.globalMatch(html);
while (reIterator.hasNext())
{
QRegularExpressionMatch match = reIterator.next();
emit newDeckCard(codeFromName(match.captured(2)), match.captured(1).toInt());
}
qDebug() << "WebUploader: "<< "Final leer deck.";
emit sendLog(tr("Web: Active deck read."));
}
}
示例8: buildQueryStringList
/**
* Builds a string list of a search string
*/
QStringList Note::buildQueryStringList(QString searchString) {
QStringList queryStrings;
// check for strings in ""
QRegularExpression re("\"([^\"]+)\"");
QRegularExpressionMatchIterator i = re.globalMatch(searchString);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
queryStrings.append(match.captured(1));
searchString.remove(match.captured(0));
}
// remove a possible remaining "
searchString.remove("\"");
// remove multiple spaces and spaces in front and at the end
searchString = searchString.simplified();
// add the remaining strings
queryStrings.append(searchString.split(" "));
// remove empty items, so the search will not run amok
queryStrings.removeAll("");
// remove duplicate query items
queryStrings.removeDuplicates();
return queryStrings;
}
示例9: getLocalDefs
QStringList getLocalDefs(QString block, ConstRegExp OUTER_REG, const uint outerCapGroup,
ConstRegExp INNER_REG, const uint innerCapGroup,
ConstRegExp REMOVE_REG = ConstRegExp() )
{
QStringList result;
QString params, currParam;
QRegularExpressionMatchIterator currMatchIter = OUTER_REG.globalMatch(block);
while (currMatchIter.hasNext() )
{
params = currMatchIter.next().captured(outerCapGroup);
QRegularExpressionMatchIterator currPartIter = INNER_REG.globalMatch(params);
while (currPartIter .hasNext() )
{
currParam = currPartIter .next().captured(innerCapGroup).remove(REMOVE_REG).remove(RX_WHITE_SPACES);
if (!currParam.isEmpty() )
result.append(currParam.split(",") );
}
}
return result;
} /* getLocalDefs */
示例10: GetSummary
QString Properties::GetSummary(const QString& key, const QVariant& v) {
QString ret;
QMap<QString, QString>::const_iterator it = summary.find(key);
if (it != summary.end()) {
ret = *it;
QRegularExpression re("(\\{.*?\\})");
QRegularExpressionMatchIterator matches = re.globalMatch(*it);
while (matches.hasNext()) {
QRegularExpressionMatch m = matches.next();
QString pattern = m.captured(0);
QString evaluated =
EvaluateSubExpression(pattern.mid(1, pattern.size() - 2), v);
// if a lookup fails, then don't return anything
if (evaluated.size() == 0) {
ret = "";
break;
}
ret.replace(pattern, evaluated);
}
} else if ((QMetaType::Type)v.type() == QMetaType::QVariantList) {
ret = QString("(%1 items)").arg(v.toList().size());
} else if ((QMetaType::Type)v.type() == QMetaType::QVariantMap) {
ret = GetSummary("", v);
}
return ret;
}
示例11: isLineMatchingBackward
bool QuickFindPattern::isLineMatchingBackward(
const QString& line, int column ) const
{
int pos = 0;
if ( ! active_ )
return false;
QRegularExpressionMatchIterator matches = regexp_.globalMatch(line);
QRegularExpressionMatch lastMatch;
while ( matches.hasNext() ) {
QRegularExpressionMatch nextMatch = matches.peekNext();
if ( column >= 0 && nextMatch.capturedEnd() >= column ) {
break;
}
lastMatch = matches.next();
}
if ( lastMatch.hasMatch() ) {
lastMatchStart_ = lastMatch.capturedStart();
lastMatchEnd_ = lastMatch.capturedEnd() - 1;
return true;
}
else {
return false;
}
}
示例12: getSectionEnums
QStringList getSectionEnums(QString §ion)
{
QStringList result;
QRegularExpressionMatchIterator currMatchIter = BL_ENUMERATED.globalMatch(section);
while (currMatchIter.hasNext() )
{
result.append(currMatchIter.next().captured(1).remove(QRegularExpression("\\s") ).split(",") );
#ifdef DEBUG
qDebug() << "\n~~~~~~\n";
#endif
int resIter;
for (resIter = 0; resIter < result.size()-1; ++resIter)
{
section.remove(result.at(resIter) );
#ifdef DEBUG
qDebug() << result.at(resIter).toLatin1().constData() << "\n";
#endif
}
#ifdef DEBUG
qDebug() << result.last().toLatin1().constData() << "\n";
#endif
}
return result;
} /* getSectionEnums */
示例13: parseLineFields
// Parse file line
void BairesWindow::parseLineFields(QString fileLine, QVector<QString> &sequence) {
QRegularExpression re("(.*?)\\s\\|");
QRegularExpressionMatchIterator i = re.globalMatch(fileLine);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
sequence.push_back(match.captured(1));
}
}
示例14: highlightBlock
void SyntaxHighlighter::highlightBlock(const QString &text) {
for (std::size_t i = 0; i < _keywords.size(); i++) {
const KeywordRule &rule = _keywords.at(i);
QRegularExpressionMatchIterator it = rule.rulePattern.globalMatch(text);
while (it.hasNext()) {
QRegularExpressionMatch match = it.next();
setFormat(
match.capturedStart(), match.capturedLength(), rule.ruleTextFormat);
}
}
}
示例15: searchReplyFinished
void BaiduMusic::searchReplyFinished()
{
QString url = searchReply->request().url().toString();
int keywordBegin = url.indexOf("key=") + 4;
int keywordEnd = url.indexOf("&start=");
int pageBeginPos = url.indexOf("start=") + 6;
int pageEndPos = url.indexOf("&size=");
//当前页
int currentPage = url.mid(pageBeginPos,pageEndPos-pageBeginPos).toInt()/PAGESIZE + 1;
//关键字
QString keyword = url.mid(keywordBegin,keywordEnd-keywordBegin);
if(searchReply->error()){
//如果出错,pageCount为-1;
emit searchComplete(currentPage,1,keyword,"{error:"+searchReply->errorString()+"}");
return;
}
//TODO:未搜索到内容的判断
QString html = searchReply->readAll();
QStringList songList;
QRegularExpression re("<li data-songitem = '(.+?)'");
QRegularExpressionMatchIterator i = re.globalMatch(html);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
QString songData = match.captured(1);
//" 替换为 " ;删除<em>和</em>
songData = songData.replace(""","\"").replace("<em>","").replace("<\\/em>","");
songList << songData;
}
//构造json数组
QString songArray = "[" + songList.join(",") + "]";
QString result = unifyResult(songArray);
//匹配总页数
QRegularExpression pageCountRe("\">(\\d+)</a>\\s*<a class=\"page-navigator-next\"");
QRegularExpressionMatch match = pageCountRe.match(html);
//页面总数
int pageCount = match.captured(1).toInt();
//如果没有 pageCount,则 pageCount 设为 1;
pageCount = pageCount>0 ? pageCount : 1;
emit searchComplete(currentPage,pageCount,keyword,result);
}