fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main() {
  5. std::string s = "AAABCAAABCDEAA";
  6. std::string::size_type start = 0, pos;
  7. while ((pos = s.find("AA", start)) != std::string::npos)
  8. {
  9. pos += 2;
  10. std::string s1 = s.substr(start, pos-start);
  11. // use s1 as needed...
  12. std::cout << s1 << std::endl;
  13. start = pos;
  14. }
  15. return 0;
  16. }
Success #stdin #stdout 0s 4948KB
stdin
Standard input is empty
stdout
AA
ABCAA
ABCDEAA