I have a .ini file and in it i declare Sections like:
[SectionName]
I want to get rid of '[' and ']' to just read in the SectionName, currently i'm using this to achieve what i want:
line.substr(1, line.size() - 2);
But this gets only rid of the first and last Character, no matter what they are. I'm looking for an elegant way to delete the first occurrence of '[' and last occurrence of ']'. Thanks in advance!
EDIT: I tried using this:
void TrimRight(std::string str, std::string chars)
{
str.erase(str.find_last_not_of(chars) + 1);
}
void TrimLeft(std::string str, std::string chars)
{
str.erase(0, str.find_first_not_of(chars));
}
TrimLeft(line, "[");
TrimRight(line, "]");
But this is not removing them, for some weird reason...