从一个字符串中提取数字 [英] Extract Digits From one String

查看:98
本文介绍了从一个字符串中提取数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个csv文件,其中某些列包含相同的参数"TakeProfit_II = 440"
我读取数据并将其保存在矢量中.我想知道如何比该字符串提取数字.
例如,提取440比"TakeProfit_II = 440"
问候,


I have one csv file that some columns are include parameters same "TakeProfit_II=440"
I read data and save all in vector. I want know how to extract digit than this string.
For example extract 440 than "TakeProfit_II=440"
Regards,

推荐答案

如果您现在可以使用数据格式,则可以简单地使用: ^ ]
If you now the format of the data could you use simply: sscanf[^]


您可以使用boost lexcical_cast.
以下是链接:
Boost Lexical cast [
You can use boost lexcical_cast.
Below is the link:
Boost Lexical cast[^]
Use this if your are already having boost. Else boost is a mega download. But boost is very good if you really want to work in hardcore C++.


您可以使用 ^ ] CString中的方法来分割字符串,并尝试仅选择数字部分
You can use Tokenize[^] metod from CString to split the string and try to select only the number part


这篇关于从一个字符串中提取数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆