Advertisement
Masterchoc

Untitled

Jun 17th, 2019
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. static inline std::vector<std::string> splitString(const std::string& str, const std::string& delimiter)
  2. {
  3.     std::vector<std::string> strings;
  4.     std::string::size_type pos = 0;
  5.     std::string::size_type prev = 0;
  6.  
  7.     while ((pos = str.find(delimiter, prev)) != std::string::npos)
  8.     {
  9.         strings.push_back(str.substr(prev, pos - prev));
  10.         prev = pos + 1;
  11.     }
  12.  
  13.     strings.push_back(str.substr(prev));
  14.  
  15.     return strings;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement