fork(9) 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 str = "The ,qu\\,ick ,\tbrown, fox"s;
  12.  
  13. const regex re{ "\\s*((?:[^\\\\,]|\\\\.)*?)\\s*(?:,|$)" };
  14. const vector<string> tokens{ sregex_token_iterator(cbegin(str), cend(str), re, 1), sregex_token_iterator() };
  15.  
  16. copy(cbegin(tokens), cend(tokens), ostream_iterator<string>(cout, "\n"));
  17. }
Success #stdin #stdout 0s 3552KB
stdin
Standard input is empty
stdout
The
qu\,ick
brown
fox