fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. bool has_id_after_last_slash(std::string const & url) {
  5. size_t last_slash = url.find_last_of('/');
  6.  
  7. if (last_slash == std::string::npos) { return false; }
  8.  
  9. return url.compare(last_slash + 1, 3, "id_") == 0;
  10. }
  11.  
  12. int main() {
  13. for (std::string line; std::getline(std::cin, line); ) {
  14. if (has_id_after_last_slash(line)) {
  15. std::cout << line << std::endl;
  16. }
  17. }
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3432KB
stdin
http://w...content-available-to-author-only...e.org/resource/id_xa5x8p_1sz_1s8rhrc
http://w...content-available-to-author-only...e.org/resource/abc
http://w...content-available-to-author-only...e.org/resource/id_xa5x8p_1sz_1s8rfcc
http://w...content-available-to-author-only...e.org/resource/def
http://w...content-available-to-author-only...e.org/resource/ghi
http://w...content-available-to-author-only...e.org/resource/id_xa5x8p_1sz_1s8ryurc
http://w...content-available-to-author-only...e.org/resource/id_xa5x8p_1sz_1s8rhrcwjf
http://anyother/anthingelse/id_xa5x8p_1sz_1s8rhrc
file://anyotherInfo/anthingelse1/id_xa5x8p_1sz_1s8rhrc
file://anyotherInfo/anthingelse1/def/id_xa5x8p_1sz_1s8rhrc
file://id_anyotherInfo/anthingelse1/def/id_xa5x8p_1sz_1s8rhrc
file://anyotherInfo/id_anthingelse1/def/id_xa5x8p_1sz_1s8rhrc
file://anyotherInfo/id_anthingelse1/def/ghi
stdout
http://w...content-available-to-author-only...e.org/resource/id_xa5x8p_1sz_1s8rhrc
http://w...content-available-to-author-only...e.org/resource/id_xa5x8p_1sz_1s8rfcc
http://w...content-available-to-author-only...e.org/resource/id_xa5x8p_1sz_1s8ryurc
http://w...content-available-to-author-only...e.org/resource/id_xa5x8p_1sz_1s8rhrcwjf
http://anyother/anthingelse/id_xa5x8p_1sz_1s8rhrc
file://anyotherInfo/anthingelse1/id_xa5x8p_1sz_1s8rhrc
file://anyotherInfo/anthingelse1/def/id_xa5x8p_1sz_1s8rhrc
file://id_anyotherInfo/anthingelse1/def/id_xa5x8p_1sz_1s8rhrc
file://anyotherInfo/id_anthingelse1/def/id_xa5x8p_1sz_1s8rhrc