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 中使用正则表达式去除匹配到的内容
最新推荐文章于 2021-09-07 13:07:00 发布