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?
Thanks.
Last edited on
str=str.substr(1,str.length()-2);
No! But thanks for trying.

I resolved with:

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

or

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

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.