fork download
  1. #include <regex>
  2. #include <string>
  3. #include <iostream>
  4.  
  5.  
  6. std::string get_date(std::string str) {
  7. static std::vector<std::regex> patterns = {
  8. std::regex{R"(^[a-zA-Z]{3},\s*(.*?)\s*\d{2}(?::\d{2}){2})"},
  9. };
  10.  
  11. for (auto& regex : patterns) {
  12. std::smatch m;
  13. if (std::regex_search(str, m, regex)) {
  14. return m[1];
  15. }
  16. }
  17. return str;
  18. }
  19.  
  20. int main() {
  21. std::cout << get_date("Fri, 01 Apr 2022 07:28:00 GMT") << std::endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 5520KB
stdin
Standard input is empty
stdout
01 Apr 2022