Tokenize a string: Difference between revisions

(Ada)
Line 55:
{
using namespace std;
// Skip delims at beginning., find start of first token
string::size_type lastPos = str.find_first_not_of(delims, 0);
// Find firstnext "non-delimiter". @ end of token
string::size_type pos = str.find_first_of(delims, lastPos);
Line 67:
// Found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// Skip delims. Note the "not_of". this is beginning of token
lastPos = str.find_first_not_of(delims, pos);
// Find next "non-delimiter" at end of token.
pos = str.find_first_of(delims, lastPos);
}