|
Boost : |
Subject: Re: [boost] [regex] Change format of data in file
From: John Maddock (jz.maddock_at_[hidden])
Date: 2015-04-26 12:37:27
On 26/04/2015 16:06, Fu ji wrote:
> Hello all,
> I have file output.txt, in file we can find something like:
>
> 01/01/2015 15:00:00 2222.2222
>
> 2222.2222 2222.2222 2222.2222
>
> 04/04/2015 15:00:00 2222.2222
>
> and i would like to change format from DD/MM/RRRR HH:MM:SS to RRRR-MM-DD
> HH:MM:SS.000 using boost regex. But I have no clue how should I type
> pattern and replace them with another.
>
> Anyone have knowledge about boost regex and could help me ?
To take only the first part of the problem, then off the top of my head,
something like:
boost::regex e("(\\d{2})/(\\d{2})/(\\d{4})");
Then if the contents of the file are in "mystring":
mystring = regex_replace(mystring, e, "$3/$2/$1");
HTH, John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk