开发者

ignoring case in libpcre with c

How do I ignore case when using pcre_com开发者_如何学Gopile 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?


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


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 */
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜