#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使用正则表达式从字符串中提取数值的全部内容,更多相关Qt使用正则表达式从字符串中提取数值内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复