Guest User

Untitled

a guest
Oct 21st, 2019
59
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. std::vector<std::string> split(const std::string& s, char delimiter = ';'){
  2. std::vector<std::string> result;
  3. std::string tmp = s;
  4.  
  5. while(tmp.find(delimiter) != std::string::npos)
  6. {
  7. std::string new_part = tmp.substr(0, tmp.find(delimiter));
  8. tmp = tmp.substr(tmp.find(delimiter)+1, tmp.size());
  9. if(not (new_part.empty()))
  10. {
  11. if(new_part.front()='"' && new_part.back()='"'){
  12. result.push_back(new_part.substr(1, new_part.size()-2));
  13. }
  14. else{
  15. result.push_back(new_part);
  16. }
  17. }
  18. }
  19. if(not tmp.empty())
  20. {
  21. if(tmp.front()='"' && tmp.back()='"'){
  22. result.push_back(tmp.substr(1, tmp.size()-2));
  23. }
  24. else{
  25. result.push_back(tmp);
  26. }
  27. }
  28. return result;
  29. }
RAW Paste Data