fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <regex>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. const auto input = "Peas&Carrots Spinach-Casserole Beets Pizza Spinach-Salad Coleslaw"s;
  11.  
  12. const regex re{ "(?:\\s+|^)(?!Spinach)(\\S+)" };
  13.  
  14. copy(sregex_token_iterator(cbegin(input), cend(input), re, 1), sregex_token_iterator(), ostream_iterator<string>(cout, "\n"));
  15. }
Success #stdin #stdout 0s 3552KB
stdin
Standard input is empty
stdout
Peas&Carrots
Beets
Pizza
Coleslaw