#include <QCoreApplication>
#include <QRegularExpression>
#include <QString>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString m = "SSLL:000001.12 ZZLL:000006488152 QQT:-1234.4";
// 定义正则表达式,其中负号是可选的
QRegularExpression re(R"((?<=SSLL:)(-?[\d.]+)\s+(?=ZZLL:)(-?\d+)\s+(?=QQT:)(-?[\d.]+))");
QRegularExpressionMatch match = re.match(m);
if (match.hasMatch()) {
double floatValue1 = match.captured(1).toDouble(); // 提取第一个浮点数
int intValue = match.captured(2).toInt(); // 提取整数
double floatValue2 = match.captured(3).toDouble(); // 提取第二个浮点数
qDebug() << "First float value:" << floatValue1;
qDebug() << "Integer value:" << intValue;
qDebug() << "Second float value:" << floatValue2;
} else {
qDebug() << "No match found!";
}
return a.exec();
}