tags:

views:

50

answers:

2

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?

+3  A: 

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.)

RichieHindle
+2  A: 

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 */
Nick D