Remove characters from string

I want to remove the initial and final " character from my string:

string str("\"aaaa\""); // "aaaa"

How can I do using standard c++ or boost library?
Last edited on
No! But thanks for trying.

I resolved with:

boost::trim_if(str, is_any_of("\""));


boost::erase_all(str, "\"");
Last edited on

You are wrong. Your task as you described it is to delete initial and final " characters.

This code

boost::erase_all(str, "\"");

does another task that is it deletes all occurence of \".

And it is a very bad practice to use boost when the task can be simply done with standard means.

So the code suggested by Athar is much better.
Last edited on
Topic archived. No new replies allowed.