#include <vector>
using namespace std;
vector<double> getNumListFromStr(const QString& str)
{
QRegExp rx("-?[1-9]\\d*\\.\\d*|0+.[0-9]+|-?0\\.\\d*[1-9]\\d*|-?\\d+");
int pos = 0;
vector<double> v;
while ((pos = rx.indexIn(str, pos)) != -1)
{
pos += rx.matchedLength();
v.push_back(rx.cap(0).toDouble());
}
return v;
}
Qt使用正则表达式从字符串中提取数值
最新推荐文章于 2023-11-05 21:55:35 发布