fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <sstream>
  5. #include <string>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11. const auto first = "Somebody"s;
  12. const auto second = "words"s;
  13. const vector<string> words = { "in"s, "lorem"s, "ipsum"s };
  14. const auto input = "Somebody has typed in some words here."s;
  15. const auto start = input.find(first) + first.size();
  16. const auto finish = input.find(second, start);
  17.  
  18. if (start != string::npos && finish != string::npos) {
  19. istringstream range(input.substr(start, finish - start));
  20.  
  21. if (none_of(istream_iterator<string>(range), istream_iterator<string>(), [&](const auto& i) { return find(cbegin(words), cend(words), i) != cend(words); })) {
  22. cout << "match\n";
  23. } else {
  24. cout << "not a match\n";
  25. }
  26. } else {
  27. cout << "not a match\n";
  28. }
  29.  
  30. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
not a match