fork(1) download
  1. #include <regex>
  2. #include <exception>
  3. #include <iostream>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. std::regex reg;
  8. try{
  9. reg = std::regex(".*[a-zA-Z]+.*");
  10. }
  11. catch(std::regex_error &e){
  12. std::cout << e.what() << std::endl;
  13. std::cout << e.code() << std::endl;
  14. if (e.code() == std::regex_constants::error_brack)
  15. std::cerr << "The expression contained mismatched brackets ([ and ]).\n";
  16. }
  17. return 0;
  18. }
Success #stdin #stdout #stderr 0s 3500KB
stdin
Standard input is empty
stdout
regex_error
4
stderr
The expression contained mismatched brackets ([ and ]).