1

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?

user105033
  • 18,800
  • 19
  • 58
  • 69

2 Answers2

4

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
  • 272,464
  • 47
  • 358
  • 399
3

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 Dandoulakis
  • 42,588
  • 16
  • 104
  • 136