|
Boost : |
From: Pavol Droba (droba_at_[hidden])
Date: 2006-10-09 14:08:38
Hi,
This *is* the correct behaviour. There were several discussions on this
topic in the past (you can search archive for more insight).
split always returns n+1 tokens where n is a number of separators. This
is deterministic and allows to reconstruct the original sequence.
Best Regards,
Pavol
luca regini wrote:
> The following code:
>
> using namespace boost::algorithm;
> std::string test("DataItem.item[4]");
> std::vector< std::string > path;
> split(path,test,is_any_of(".[]"),token_compress_on);
> for(int i=0;i<path.size();i++)
> {
> const char* dbg=path[i].c_str();
> std::cout<<path[i]<<std::endl;
> }
> std::cout<<" DONE!"<<std::endl;
>
> produces the following output:
>
> DataItem
> 4
> <null string>
> DONE!
>
> This happens every time the test string ends with a terminator.
> Is this the desired behaviour? It seems to me that it is more
> intuitive if the split returns just the first two items without the
> final <null> string.
>
> Regards,
> Luca Regini
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk