Skip to main content

Timeline for How do I tokenize a string in C++?

Current License: CC BY-SA 3.0

11 events
when toggle format what by license comment
Aug 13, 2017 at 20:11 comment added user5818995 Why not allow empty string as a delimiter too?
May 23, 2017 at 11:47 history edited URL Rewriter Bot
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Sep 6, 2013 at 12:40 history edited user283145 CC BY-SA 3.0
use a better reference (see http://meta.stackoverflow.com/questions/194788)
Jun 26, 2013 at 14:02 comment added Lauri Nurmi @JohnK If the input has two consecutive delimiters, then clearly the string between them is empty, and should be inserted into the vector. If empty values are not acceptable for a particular purpose, that is another thing, but IMHO such constraints should be enforced outside this kind of a very general purpose functions.
Jun 25, 2013 at 11:04 review Suggested edits
Jun 25, 2013 at 11:06
Jul 31, 2012 at 20:11 comment added John K I think the last line in the while loop should be start = ((end > (theString.size() - theDelimiter.size())) ? string::npos : end + theDelimiter.size()); and the while loop should be while (start != string::npos). Also, I check the substring to be sure it's not empty before inserting it into the vector.
Apr 18, 2012 at 20:34 comment added Mr. Shickadance Ugh, why doesn't the std::string class include a split() function?
Mar 17, 2012 at 17:03 comment added GhassanPL Maybe the UASSERT macro shows (in the error message) the actual relationship between (and values of) the two compared values? That's actually a pretty good idea, IMHO.
Feb 27, 2012 at 16:13 history edited Peter Mortensen CC BY-SA 3.0
Moved meta information to the end.
May 13, 2011 at 13:10 comment added crelbor Why define a macro you only use in one place. And how is your UASSERT any better than standard assert. Splitting up the comparison into 3 tokens like that does nothing other than require more commas than you'd otherwise need.
Nov 28, 2008 at 2:55 history answered Mr.Ree CC BY-SA 2.5