Maybe someone can tell me what's going on here?
My intention is to break the input string into curly braces: ie: ( 'or ) .
For the input line "(good) hello (there) of the world" I expect 4 tokens to be returned: good; Hello; there; peace.
As you can see from my sample application below, I get 5 tokens back (the first is an empty string).
Is there any way to get this to return only non-empty lines to me ?
#include <iostream> #include <boost/algorithm/string.hpp> #include <vector> int main() { std::string in = "(well)hello(there)world"; std::vector<std::string> tokens; boost::split(tokens, in, boost::is_any_of("()")); for (auto s : tokens) std::cout << "\"" << s << "\"" << std::endl; return 0; }
Output:
$ a.out "" <-- where is this token coming from? "well" "hello" "there" "world"
I tried using boost::algorithm::token_compress_on but I get the same result.
source share