regex.hpp 613 B

1234567891011121314151617181920212223
  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. class Regex {
  9. pcre2_code *re; // 正则表达式
  10. const std::string pattern; // 正则表达式的字符串
  11. public:
  12. AFUN_TOOL_EXPORT explicit Regex(const std::string &pattern_);
  13. AFUN_TOOL_EXPORT ~Regex ();
  14. AFUN_TOOL_EXPORT int match(const char *subject);
  15. AFUN_TOOL_EXPORT int match(const std::string &subject) {return match(subject.c_str());}
  16. };
  17. }
  18. #endif //AFUN_REGEX