Advertisement
spacechase0

Tokenize

May 15th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1.     std::vector< std::string > tokenize( const std::string& str, const std::string& symbol )
  2.     {
  3.         std::vector< std::string > toReturn;
  4.  
  5.         size_t start = 0;
  6.         for ( size_t found = str.find( symbol, start ); found != std::string::npos; found = str.find( symbol, start ) )
  7.         {
  8.             toReturn.push_back( str.substr( start, found - start ) );
  9.             start = found + symbol.length();
  10.         }
  11.         toReturn.push_back( str.substr( start ) );
  12.  
  13.         return toReturn;
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement