fork download
  1. // C++ program to split
  2. // string into substrings
  3. // which are separated by
  4. // separator using boost::split
  5.  
  6. // this header file contains boost::split function
  7. #include <bits/stdc++.h>
  8. #include <boost/algorithm/string/split.hpp>
  9. #include <boost/algorithm/string/classification.hpp>
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. string input("bla&bla");
  15. vector<string> result;
  16. boost::split(result, input, boost::is_any_of("&"));
  17.  
  18. for (int i = 0; i < result.size(); i++)
  19. {
  20. if (result[i].empty()) cout << "'empty'";
  21. else cout << result[i] << endl;
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
bla
bla