string strMsg = "MainWindow::createMeasurePage(): dvctype=DvcMisc,cmd=WELCM,logonuser=adf";
QTextCodec * codec = QTextCodec::codecForName("UTF-8");
QString qstr = codec->toUnicode(strMsg.c_str(), strMsg.length());
QString strRx("^[a-zA-Z][a-zA-Z0-9_]*::[a-zA-Z][a-zA-Z0-9_]*\\(\\):\\s");
QRegExp rxlen(strRx);
int pos = rxlen.indexIn(qstr);
if (pos > -1) {
QString value = rxlen.cap(0); //
QString unit = rxlen.cap(1); //
qDebug() << value << unit << pos <<"match over";
}
//*/
// QString strTmp = "MainWindow::createMeasurePage(): dvctype=DvcMisc,cmd=WELCM,logonuser=adf";
qstr.replace(rxlen, "");
qDebug() << qstr << "return" << endl;
qt 中使用正則表達式去除匹配到的內容
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.