Created
July 22, 2015 11:30
-
-
Save clauswitt/c22c9b94f13d472f79e3 to your computer and use it in GitHub Desktop.
Trim a string with boost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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