mardi 24 octobre 2017

Selectively replace (") doublequotes in a std::string in C++

I want to selectively replace the (") doublequotes in a C++ std::string. i.e. i want to replace all occurences of (") doublequotes in a string except the 1st and last occurence of (") doublequotes in the string.

Example- following code replaces ALL occurence of (") doublequotes

std::string str = "\"Hello people \" how are you doing \" what are \" you upto \"";
str = std::regex_replace(str, std::regex("\\\""), """);

However, i don't want to replace the 1st and last occurenece of the string.

i.e. in the string i don't want to replace (") just before "Hello" & the one at the end.

std::string str = "\"Hello people \" how are you doing \" what are \" you upto \"";

Aucun commentaire:

Enregistrer un commentaire