How To split/explode a std::string ?
Given a std::string, for example “XXX_YYY_ZZZ”, how to explode it with “_” as separator ?
Using boost’s split function :
std::string str("XXX_YYY_ZZZ"); // The string to explode
std::vector<std::string> StrVec; // The container
split( StrVec, str, is_any_of("_") ); // StrVec == { "XXX","YYY","ZZZ" }
romain @ April 6, 2009
Another option is to read this page