fork download
  1. #include <iostream>
  2. #include <regex.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. regex_t regex;
  9.  
  10. int result = regcomp(&regex, "([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})", REG_EXTENDED);
  11. if(result){
  12. cout<<"ERROR"<<endl;
  13. }
  14.  
  15.  
  16. result = regexec(&regex, "Blah blah blah 2015/11/03 20:25:50 blah blah blah", 0, NULL, 0);
  17. if(!result){
  18. cout<<"MATCH: " << result <<endl;
  19. }
  20. else if(result == REG_NOMATCH){
  21. cout<<"NO MATCH"<<endl;
  22. }
  23. else{
  24. char msg[100];
  25. regerror(result, &regex, msg, 100);
  26. cout<<msg<<endl;
  27. }
  28.  
  29. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
MATCH: 0