Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
char Sample[32]={0};


and Samplehas the data as following format
eg1.075/OFCI1234.12/OFGI1111.11
eg2.088/OFCI33211221.1/OFGI99
eg3.099/OFCI9/OFGI11111111111111.11




Here the format is fixed XXX/OFCIxxxx.xxxxx/OFGIyyyyy.yyy


how to extract the data:xxxx.xxxxx and yyyyy.yyy into separate strings.
Posted
Updated 20-Oct-15 1:32am
v2

1 solution

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+)?)


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.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900