fork download
  1. #include <regex>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main() {
  7. string s("Location: http://w...content-available-to-author-only...e.ru/ru/index.php?gfe_rd=cr&ei=wHKcWInnDurA7gThta_YBw");
  8. regex r(R"(Location:\s+([a-z]+)://(?:www\.)?([^/]+)/?([^?]*)(?:\?(.*))?)");
  9. smatch matches;
  10. if (regex_match(s, matches, r)) {
  11. cout << "Протокол: " << matches.str(1) << endl;
  12. cout << "Домен: " << matches.str(2) << endl;
  13. cout << "Путь: " << matches.str(3) << endl;
  14. cout << "Строка запроса: " << matches.str(4) << endl;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 16160KB
stdin
Standard input is empty
stdout
Протокол: http
Домен: gogggle.ru
Путь: ru/index.php
Строка запроса: gfe_rd=cr&ei=wHKcWInnDurA7gThta_YBw