I need to convert data from a file to a double and sometimes the data is in the form:
0.3387000000D+02 0.6067999217D-02
0.5095000000D+01 0.4530799416D-01
0.1159000000D+01 0.2028219738D+00
0.3258000000D+00 0.5039029350D+00
0.1027000000D+00 0.3834209505D+00
How would you tackle handling the D
here?
This is scientific notation just with a D
instead of an E
.
I am thinking using std::regex
here but am hoping for a more elegant strategy.
Something like the following:
std::regex rr( "((\\+|-)?[[:digit:]]+)(\\.(([[:digit]]+)?))?(d|D)((\\+|-)?)[[:digit:]]+)""?");