0
選擇第一個字符串如何獲得使用QRegularExpression使用QRegularExpression
第一個字符串("firstStr"
下面的例子)
QString readCmdOutput = "";
/* readCmdOutput = "firstStr\secondStr"; or
readCmdOutput = "firstStr
secondStr
"
*/
readCmdOutput = QString::fromLocal8Bit(myProcess->readAllStandardOutput());
QRegularExpression re("REGEXPRESSION");
QRegularExpressionMatch match = re.match(readCmdOutput);
if (match.hasMatch()) {
QString matched2 = match2.captured(0); // has to contain "firstStr"
}