拆分和格式化char数组 [英] splitting and formatting char array
本文介绍了拆分和格式化char数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
char Sample[32]={0};
和Sample的数据格式如下
and Samplehas the data as following format
eg1.075/OFCI1234.12/OFGI1111.11
eg2.088/OFCI33211221.1/OFGI99
eg3.099/OFCI9/OFGI11111111111111.11
这里的格式是固定的XXX / OFCIxxxx.xxxxx / OFGIyyyyy.yyy < br $> b $ b
如何将数据提取:xxxx.xxxxx和yyyyy.yyy分成单独的字符串。
Here the format is fixed XXX/OFCIxxxx.xxxxx/OFGIyyyyy.yyy
how to extract the data:xxxx.xxxxx and yyyyy.yyy into separate strings.
推荐答案
您可以使用正则表达式。
请参阅 C ++正则表达式使用std :: regex [ ^ ]
将从输入数据中挑选数字字符串的正则表达式示例。
You can use a regular expression for this.
See C++ Regular Expressions with std::regex[^]
Example of regular expression that will pick out the number strings from the input data.
/OFCI(?<group1>\d+(\.\d+)?)/OFGI(?<group2>\d+(\.\d+)?)
表达式\d +(\。\\\ +)?将一些格式1111.222或111放入一个组中。
这部分(\.\d +)?意味着它是可选的。
The expression \d+(\.\d+)? will put a number of the format 1111.222 or 111 into a group.
This part (\.\d+)? means it is optional.
这篇关于拆分和格式化char数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文