fork(2) download
  1. #include <iostream>
  2. #include <regex>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. string str("The ,quick brown. fox \"99\" named quick_joe!");
  8.  
  9. regex reg(R"(\d+|[^\W\d]+|[^\w\s])");
  10. sregex_token_iterator iter(str.begin(), str.end(), reg), end;
  11. vector<string> vec(iter, end);
  12. for (auto a : vec) {
  13. cout << a << ":";
  14. }
  15. cout << endl;
  16. }
Success #stdin #stdout 0s 15344KB
stdin
Standard input is empty
stdout
The:,:quick:brown:.:fox:":99:":named:quick_joe:!: