fork download
  1. #include <iostream>
  2. #include <regex>
  3. using namespace std;
  4.  
  5. int main() {
  6. regex re("'[^']+'");
  7. std::string s = "arg1('FooBar') arg2('Another Value')";
  8.  
  9. sregex_token_iterator i(s.begin(), s.end(), re);
  10. sregex_token_iterator j;
  11.  
  12. unsigned count = 0;
  13. while(i != j)
  14. {
  15. cout << "the token is"<<" "<<*i++<< endl;
  16. count++;
  17. }
  18. cout << "There were " << count << " tokens found." << endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 16168KB
stdin
Standard input is empty
stdout
the token is   FooBar
the token is   Another Value
There were 2 tokens found.