fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <regex>
  4.  
  5. int main()
  6. {
  7. std::string search_term = "apples oranges";
  8. search_term = std::regex_replace(search_term, std::regex("\\s+"), ".*");
  9.  
  10. std::string term = "apples pears oranges";
  11. std::smatch matches;
  12.  
  13. std::string url = "https://a...content-available-to-author-only...m.com/e/is/7ece90d";
  14. std::string amazon_regex = "^https://[a-z\d\-]+\.amazon-adsystem\.com/";
  15.  
  16. if (std::regex_search(url, matches, std::regex(amazon_regex)))
  17. std::cout << "Match: " << matches[0] << std::endl;
  18. else
  19. std::cout << "No match!" << std::endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Match: https://a...content-available-to-author-only...m.com/