#include <boost/algorithm/string.hpp>
#include <boost/tokenizer.hpp> //May be needed
using namespace std;
using namespace boost;
using namespace boost::algorithm;
http://www.boost.org/doc/libs/1_56_0/doc/html/string_algo.html
http://theboostcpplibraries.com/boost.stringalgorithms
Alter supplied string vs Create a new string from the output
Many of the string functions some in function_name() and function_name_copy() versions, where the _copy() version returns the output and the non _copy() version instead alters the supplied string.
Test A String
Does string contain
if (contains(my_string, "hello")
//do something
Get Portions Of A String
Trim
trim(temp_string);
Get string up to first
Read each line of a sting
string text("apple\n\norange\npair");
typedef boost::tokenizer<boost::char_separator<char> > line_tokenizer;
line_tokenizer tok(text, boost::char_separator<char>("\n\r"));
for (line_tokenizer::const_iterator i = tok.begin(), end = tok.end(); i != end ; ++i) //Get each line of the string, skipping past blank lines
std::cout << "A:" << *i << std::endl;
Split up a string by character
string my_text = "07/3/2011";
vector<string> split_line_elements;
boost::split(split_line_elements, my_text, boost::is_any_of("/"));
if (split_line_elements.size() > 0)
//do something
Remove Bits Of A String
Remove all occurances of a character
boost::erase_all(my_string, "a");
