void Notice::slotUpdate(QNetworkReply* reply){ QByteArray array; array = reply->readAll(); QString str_temp; str_temp = array; int pos = 0; QRegExp reg("<a>(.)</a>"); reg.setMinimal(true); QStringList strl; while(pos = reg.indexIn(str_temp, pos) != -1){ strl << reg.cap(1); pos += reg.matchedLength(); } for(int i = 0; i < strl.size(); i++){ qDebug() << strl.at(i); }}
C++ (Qt) QByteArray array = "Web page <a>hallo</a> ... <a>hallo2</a>"; QString str_temp; str_temp = array; int pos = 0; QRegExp reg("<a>(.*)</a>"); reg.setMinimal(true); QStringList strl; while((pos = reg.indexIn(str_temp, pos)) != -1){ strl << reg.cap(1); pos += reg.matchedLength(); } for(int i = 0; i < strl.size(); i++){ qDebug() << strl.at(i); // почему не // qDebug() << strl; }
C++ (Qt) QString data = "Web page <a>hallo</a> ... <a>hallo2</a>"; int pos = 0; QRegExp reg("<a>(.*)</a>"); reg.setMinimal(true); QStringList strl; while((pos = reg.indexIn(data, pos)) != -1){ strl << reg.cap(1); pos += reg.matchedLength(); } qDebug() << strl;