
Hi,
I use boost::tokenizer for this problem.
Example
int split(std::vectorstd::string& list, const std::string& eingabe,
const std::string& delims, bool keep_empty)
{
list.clear();
boost::empty_token_policy empty_tokens;
if( keep_empty) empty_tokens = boost::keep_empty_tokens;
else empty_tokens = boost::drop_empty_tokens;
boost::char_separator<char> sep(delims.c_str(), "", empty_tokens);
typedef boost::tokenizer
Hi, I want to tokenize a string based on one or multiple space or tab
std::string s = " a b c d \te "; std::vectorstd::string tokens; boost::algorithm::split(tokens,s,boost::algorithm::is_any_of(" \t"),token_compress_on); copy(tokens.begin(),tokens.end(),ostream_iterator<string>(cout,"\n"));
This gives more or less correct result, except it does not remove space/ tab from begin /end. It can be done like trim(s); and then call the above. But is there any other way it can be done in split itself ?
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users