Question

How do I ignore case when using pcre_compile and pcre_exec?

pcre_exec(
    pcre_compile(pattern,0,&error,&erroroffset,0),
    0, string, strlen(string), 0, 0, ovector, sizeof(ovector));

what option do i use and where do i specify it?

Was it helpful?

Solution

You need to pass PCRE_CASELESS in the second argument to pcre_compile, like this:

pcre_compile(pattern, PCRE_CASELESS, ...

(Note that you're leaking memory there - you need to call pcre_free on the object returned by pcre_compile.)

OTHER TIPS

You can use the PCRE_CASELESS flag in the pcre_compile.

Example:

  pcre_compile(
    pattern,              /* the pattern */
    PCRE_CASELESS|PCRE_MULTILINE,                    /* default options */
    &error,               /* for error message */
    &erroffset,           /* for error offset */
    NULL);                /* use default character tables */
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top