fork download
  1. #include <regex>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. void process(string inp);
  8.  
  9. int main() {
  10.  
  11. string inp;
  12. char c;
  13. int test;
  14. cin>>test;
  15. cin.ignore();
  16. while(test--)
  17. {
  18. getline(cin,inp);
  19. cout<<inp<<endl;
  20. process(inp);
  21. }
  22. return 0;
  23. }
  24.  
  25. void process(string inp)
  26. {
  27. string panex= "[A-Za-z]{5}\\d{4}[A-Za-z]{1}";
  28. regex panreg(panex,regex_constants::basic);
  29.  
  30. if(regex_match(inp,panreg))
  31. {
  32. cout<<"YES"<<endl;
  33. }
  34. else
  35. {
  36. cout<<"NO"<<endl;
  37. }
  38. }
Success #stdin #stdout 0s 3512KB
stdin
3
ABCDS1234Y
ABAB12345Y
avCDS1234Y
stdout
ABCDS1234Y
NO
ABAB12345Y
NO
avCDS1234Y
NO