Tokenize a string: Difference between revisions
Content added Content deleted
(Ada) |
|||
Line 55:
{
using namespace std;
// Skip delims at beginning
string::size_type lastPos = str.find_first_not_of(delims, 0);
// Find
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
pos = str.find_first_of(delims, lastPos);
}
|