Is there a way to remove punctuation specifically from the beginning and end of a string, while leaving contractions and possessives alone?
e.g "!wow!" would become "wow" and "can't" would stay "can't"
Is there a way to remove punctuation specifically from the beginning and end of a string, while leaving contractions and possessives alone?
e.g "!wow!" would become "wow" and "can't" would stay "can't"
You can do that with boost::trim_if
:
std::string a = "!wow!";
boost::trim_if(a, [](char c) { return std::ispunct(c); });
std::cout << a << '\n';
Outputs:
wow