This question risks being a duplicate e.g. remove double quotes from a string in c++
but none of the asnwers that I saw addresses my question
I have a list of strings, some of which are double quoted and some aren't, Quotes are always at beginning and end
std::vector<std::string> words = boost::assign::list_of("words")( "\"some\"")( "of which")( "\"might\"")("be quoted");
I am looking for the most efficient way to remove the quotes. Here is my attempt
for(std::vector<std::string>::iterator pos = words.begin(); pos != words.end(); ++pos)
{
boost::algorithm::replace_first(*pos, "\"", "");
boost::algorithm::replace_last(*pos, "\"", "");
cout << *pos << endl;
}
Can I do better than this? I have potentially hundreds of thousands of string to process.They may come from a file or from a database. The std::vector in the example is just for illustration purposes.