fork download
  1. #include <iostream>
  2. #include <regex>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. const auto foo = "aaa&bbb*ccc%ddd&eee"s;
  10. const regex re{ "((?:^|[&*%])[^&*%]*)" };
  11. const vector<string> bar{ sregex_token_iterator(cbegin(foo), cend(foo), re, 1), sregex_token_iterator() };
  12.  
  13. for(const auto& i : bar) cout << i << endl;
  14. }
Success #stdin #stdout 0s 4340KB
stdin
Standard input is empty
stdout
aaa
&bbb
*ccc
%ddd
&eee