Here's how I did it in straight C++ with STL before. Can I do something similar in Qt?

Qt Code:
  1. void ParseSentence( string& mSentence,
  2. string& mDelimiters,
  3. vector<string>& mFields )
  4. {
  5. // Skip delimiters at beginning.
  6. string::size_type lastPos = mSentence.find_first_not_of( mDelimiters, 0);
  7. // Find first "non-delimiter".
  8. string::size_type pos = mSentence.find_first_of( mDelimiters, lastPos);
  9.  
  10. while (string::npos != pos || string::npos != lastPos)
  11. {
  12. // Found a token, add it to the vector.
  13. mFields.push_back( mSentence.substr( lastPos, pos - lastPos ) );
  14. // Skip delimiters. Note the "not_of"
  15. lastPos = mSentence.find_first_not_of( mDelimiters, pos );
  16. // Find next "non-delimiter"
  17. pos = mSentence.find_first_of( mDelimiters, lastPos );
  18. }
  19. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. example of usage:
  2. // Parse sentence
  3. ParseSentence( str,
  4. string(", *"),
  5. str_fields );
To copy to clipboard, switch view to plain text mode