Some others have asked about
- how to remove an arbitrary substring from a string in c++.
- how to check whether a string ends with a given prefix
- how to check whether a string ends with a given suffix
However, it has not yet been asked how to remove a prefix or a suffix from a string in c++. Assuming that we know that a given string starts with a specific prefix/suffix, some specialized methods may be used.
So: Given the following, how do we remove the prefix and suffix?
std::string prefix = "prefix.";
std::string suffix = ".suffix";
std::string full_string = "prefix.content.suffix";
std::string just_the_middle = ???;