Replace double single quote (' ') with a single quote (')

Viewed 1122

Suppose I have a string :

argsStr = "server ('m1.labs.terad  ''ata.com') username ('us ''er5') password('user)5') dbname ('def\\ault')";

Now I am using the following code to extract the tokens:

'm1.labs.terad  ''ata.com'  <- token1
'us ''er5'                    <-token2
'user)5'                    <-token3
'def\ault'                  <-token4

Code:

regex re("(\'(.*?)\'\)");
typedef std::vector<std::string> StringVector;
StringVector arg_values;
boost::regex re_arg_values("('[^']*(?:''[^']*)*')");
boost::sregex_token_iterator name_iter_start(argsStr.begin(),argsStr.end(), re_arg_values, 0),name_iter_end;
std::copy(value_iter_start, value_iter_end,std::back_inserter(arg_values)); 
//putting the token in the string vector.

Now after putting it into the string vector, How can I convert the tokens/ string to replace double quotes with single quotes:

For example:

'm1.labs.terad ''ata.com' should become 'm1.labs.terad 'ata.com' and 'us ''er5' should become 'us 'er5'.

Can I use boost::replace_all for this?

2 Answers
Related