fork download
  1. #include <regex>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main() {
  7. regex check(R"(\([-+]?\d+,[-+]?\d+\))");
  8. string s1("(44,45)");
  9. string s2("(44,45");
  10. smatch match;
  11. if (regex_match(s1, match, check)) {
  12. cout << s1 << ": Matched!" << endl;
  13. } else {
  14. cout << s1 << ": Not matched!" << endl;
  15. }
  16. if (regex_match(s2, match, check)) {
  17. cout << s2 << ": Matched!" << endl;
  18. } else {
  19. cout << s2 << ": Not matched!" << endl;
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 16160KB
stdin
Standard input is empty
stdout
(44,45): Matched!
(44,45: Not matched!