fork download
  1. #include <iostream>
  2. #include<string>
  3. using namespace std;
  4. #include<regex.h>
  5. #include<stdio.h>
  6.  
  7.  
  8. int main()
  9. {
  10. string mon;
  11. cin>>mon;
  12. cout << mon << endl;
  13. string exp_month = mon;
  14. string monthRegex = "0[1-9]\\|1[0-2]";
  15. regex_t preg;
  16. int rc;
  17.  
  18. if (0 != (rc = regcomp(&preg, monthRegex.c_str(), REG_NOSUB))) {
  19. cout<<("regcomp() failed, returning nonzero (%d)\n", rc);
  20. exit(EXIT_FAILURE);
  21. }
  22.  
  23.  
  24. if (regexec(&preg,exp_month.c_str(),0,NULL,0)==0)
  25. {
  26. cout<<"yess";
  27. }
  28. else
  29. {
  30. cout<<"no";
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 3472KB
stdin
09
stdout
09
yess