Boost logo

Boost :

From: luca regini (luca.regini_at_[hidden])
Date: 2006-10-09 07:20:03


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk