Search code examples
cregexapr

apr-utils apr_strmatch regex syntax


I want to port the following regex from python:

HASH_REGEX = re.compile("([a-fA-F0-9]{32})")
if HASH_REGEX.match(target):
    print "We have match"

to C with apr-utils apr_strmatch function:

pattern = apr_strmatch_precompile(pool, "([a-fA-F0-9]{32})", 0);
if (NULL != apr_strmatch(pattern, target, strlen(target)) {
    printf("We have match!\n");
}

The problem is that I don't understand what syntax of regex (or dialect) apr-utils apr_strmatch function is using. Search for documentation and examples ended with no results.

Thanks for your advices in advance...


Solution

  • apr_strmatch doesn't do regular expression matching at all; it does ordinary substring search using the Boyer–Moore–Horspool algorithm (see source).

    For RE matching in C, try PCRE.