Skip to content

Instantly share code, notes, and snippets.

@clauswitt
Created July 22, 2015 11:30
Show Gist options
  • Save clauswitt/c22c9b94f13d472f79e3 to your computer and use it in GitHub Desktop.
Save clauswitt/c22c9b94f13d472f79e3 to your computer and use it in GitHub Desktop.
Trim a string with boost
#include <iostream>
#include <string>
#include <boost/algorithm/string/trim.hpp>
#include <boost/algorithm/string/trim_all.hpp>
int main() {
std::string result;
std::string str01 = " this is a string with something to trim ";
result = boost::trim_left_copy(str01);
std::cout << "|" << result << "|" << std::endl;
result = boost::trim_right_copy(str01);
std::cout << "|" << result << "|" << std::endl;
result = boost::trim_all_copy(str01);
std::cout << "|" << result << "|" << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment