fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <regex>
  4.  
  5. int main(int argc, char** argv) {
  6. const std::string line("[27/Apr/2015:06:53:30 -0400] GET file.txt HTTP/1.1 206");
  7. const std::regex re("GET (.+) HTTP");
  8. std::cout << "Line: " << line << std::endl;
  9. std::smatch match;
  10. if(std::regex_search(line, match, re)) {
  11. std::cout << "Match: " << match[1] << std::endl;
  12. }
  13. }
Success #stdin #stdout 0s 3364KB
stdin
Standard input is empty
stdout
Line: [27/Apr/2015:06:53:30 -0400] GET file.txt HTTP/1.1 206
Match: file.txt