tool-regex.cpp 641 B

12345678910111213141516171819202122232425262728
  1. #include <cstdio>
  2. #include <iostream>
  3. #include "aFuntool.h"
  4. int main() {
  5. aFuntool::Regex rg {"Hello嘿.*d"};
  6. int rc1 = rg.match("Hello嘿World");
  7. int rc2 = rg.match("Nossss");
  8. if (rc1 != 1 || rc2 != 0) {
  9. printf("Failed rg1: %d/1, %d/0\n", rc1, rc2);
  10. return 1;
  11. } else
  12. printf("rg1 success\n");
  13. aFuntool::Regex rg2 {"你|好"};
  14. int rc3 = rg2.match("你");
  15. int rc4 = rg2.match("Nosssss");
  16. if (rc3 != 1 || rc4 != 0) {
  17. printf("Failed rg2: %d/1, %d/0\n", rc1, rc2);
  18. return 1;
  19. } else
  20. printf("rg2 success\n");
  21. printf("All success\n");
  22. return 0;
  23. }