Opened 17 years ago
Closed 17 years ago
#534 closed Bugs (None)
problem with boost::algorithm::split
| Reported by: | liner | Owned by: | memring |
|---|---|---|---|
| Milestone: | Component: | None | |
| Version: | None | Severity: | |
| Keywords: | Cc: |
Description
string str("*word1-word2*word3-");
vector<std::string> ResultCopy;
split(ResultCopy, str, is_any_of("-*"), token_compress_on);
for(unsigned int nIndex=0; nIndex<ResultCopy.size();
nIndex++)
{
cout << nIndex << ":" << ResultCopy[nIndex] << endl;
};
The output is:
0:
1:word1
2:word2
3:word3
4:
Is this a bug?
In my opinion the output should be:
0:word1
1:word2
2:word3
Change History (2)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
| Status: | assigned → closed |
|---|
Note:
See TracTickets
for help on using tickets.

Logged In: YES user_id=635808 The current behaviour is not a bug, rather the former one was not correct. Based on the long discussion on both developer's and user's list, the implementation was changed to always return n+1 tokens where n is number of separators. No empty tokens are removed, event if they are on the endings of the input string. You can simulate the deprecated behaviour simply by trimming the input before the split operation. Just add boost::trim_if(str, is_any_of("*-") before split. Regards, Pavol