fork download
  1. #include <regex>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. try {
  8. regex R(R"(^([^;]+);(?:\s*([^=]+)=((\"?)([^\"]*)\4);?)*$)");
  9. string s("attached; filename=\"Hello, world!.docx\"");
  10. smatch m;
  11. if (regex_search(s, m, R)) {
  12. std::cout << m[0] << std::endl;
  13. }
  14. }
  15. catch (const regex_error& e) {
  16. cout << "regex_error caught: " << e.what() << '\n';
  17. if (e.code() == regex_constants::error_brack) {
  18. cout << "The code was error_brack\n";
  19. }
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 4824KB
stdin
Standard input is empty
stdout
attached; filename="Hello, world!.docx"