#include <string>
#include <boost/regex.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
using namespace boost;
string filter( const string in )
{
regex expr("\"(\\w+):(\\w+)%(\\w+)\"");
string fmt("$1:$2*$3,\n");
ostringstream ostring;
ostream_iterator<char> oi(ostring);
regex_replace( oi, in.begin(), in.end(), expr, fmt, (match_default | format_no_copy) );
return ostring.str();
}
int main(int argc, const char* argv[])
{
if( argc < 3 )
{
cout<< "Please enter 2 filenames(e.g. In.txt Out.txt)" << endl;
return 1;
}
ifstream in( argv[1] );
ofstream out( argv[2] );
ostringstream buf;
buf << in.rdbuf();
out << filter( buf.str() ) << flush;
}