Lars Gullik Bjønnes <[EMAIL PROTECTED]> writes: > | If this is meant to be code to read a comma-separated list, then it's not > | robust. This file can be edited by hand... > > If you edit it by hand you are on your own. > But sure if we can make it more robust.
> | Bo, have a look at Boost.Tokenizer. It's ideally suited to, well, > | tokenizing > Perhaps boost::regex will be even easier. I don't think so. #include <iostream> #include <boost/tokenizer.hpp> #include <string> int main() { std::string const data = "This is, a test"; typedef boost::tokenizer<boost::char_separator<char> > Tokenizer; // Tokenize on spaces and commas. // Discard empty tokens. boost::char_separator<char> sep(" ,"); Tokenizer tokens(data, sep); Tokenizer::iterator const end = tokens.end(); for (Tokenizer::iterator it = tokens.begin(); it != end; ++it) std::cout << "<" << *tok_iter << "> "; std::cout << "\n"; return EXIT_SUCCESS; }