fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. #include <boost/tokenizer.hpp>
  5.  
  6. int main() {
  7. std::wstring str = L"2 , 14 33 50 \"AAA BBB\"";
  8.  
  9. std::wstring escSep(L"\\");//escape character
  10. std::wstring delim(L" \t\r\n,");//split on spaces, tabs, new lines, commas
  11. std::wstring quotes(L"\"");//allow double-quoted values with delimiters within
  12.  
  13. boost::escaped_list_separator<wchar_t> separator(escSep, delim, quotes);
  14. boost::tokenizer<boost::escaped_list_separator<wchar_t>, std::wstring::const_iterator, std::wstring> tok(str, separator);
  15.  
  16. for(auto beg=tok.begin(); beg!=tok.end();++beg)
  17. std::wcout << *beg << std::endl;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 15256KB
stdin
Standard input is empty
stdout
2



14
33
50

AAA BBB