2
0

regex.hpp 643 B

12345678910111213141516171819202122232425
  1. #ifndef AFUN_REGEX
  2. #define AFUN_REGEX
  3. #define PCRE2_CODE_UNIT_WIDTH 8
  4. #include "pcre2.h"
  5. #include "aFunToolExport.h"
  6. namespace aFuntool {
  7. const int REGEX_ERROR_SIZE = 512;
  8. AFUN_TOOL_EXPORT class Regex {
  9. pcre2_code *re; // 正则表达式
  10. const std::string pattern; // 正则表达式的字符串
  11. public:
  12. explicit Regex(const std::string &pattern_);
  13. Regex(const Regex &regex);
  14. Regex &operator=(const Regex &regex);
  15. ~Regex ();
  16. int match(const char *subject);
  17. int match(const std::string &subject) {return match(subject.c_str());}
  18. };
  19. }
  20. #endif //AFUN_REGEX