fork(25) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <regex>
  5. #include <string>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11. const auto input = "please split,this,csv, ,line,\\,\n"s;
  12. const regex re{ "((?:[^\\\\,]|\\\\.)+)(?:,|$)" };
  13. const vector<string> m_vecFields{ sregex_token_iterator(cbegin(input), cend(input), re, 1), sregex_token_iterator() };
  14.  
  15. cout << input << endl;
  16.  
  17. copy(cbegin(m_vecFields), cend(m_vecFields), ostream_iterator<string>(cout, "\n"));
  18. }
Success #stdin #stdout 0s 3560KB
stdin
Standard input is empty
stdout
please split,this,csv, ,line,\,

please split
this
csv
 
line
\,