24 int errorcode, offset;
28 int options = PCRE_UTF8;
32 while (!(re->
regex = pcre_compile2(
pattern, options, &errorcode, &error, &offset, NULL))) {
35 if (errorcode == 32) {
36 options &= ~PCRE_UTF8;
39 ELOG(
"PCRE regular expression compilation failed at %d: %s\n",
49 ELOG(
"PCRE regular expression studying failed: %s\n", error);
79 LOG(
"Regular expression \"%s\" matches \"%s\"\n",
84 if (rc == PCRE_ERROR_NOMATCH) {
85 LOG(
"Regular expression \"%s\" does not match \"%s\"\n",
90 ELOG(
"PCRE error %d while trying to use regular expression \"%s\" on input \"%s\", see pcreapi(3)\n",
struct regex * regex_new(const char *pattern)
Creates a new 'regex' struct containing the given pattern and a PCRE compiled regular expression.
bool regex_matches(struct regex *regex, const char *input)
Checks if the given regular expression matches the given input and returns true if it does.
void regex_free(struct regex *regex)
Frees the given regular expression.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...
void * scalloc(size_t num, size_t size)
Safe-wrapper around calloc which exits if malloc returns NULL (meaning that there is no more memory a...
Regular expression wrapper.