使用 c 忽略 libpcre 中的大小写

发布于 2024-08-09 06:45:42 字数 231 浏览 1 评论 0原文

使用 pcre_compile 和 pcre_exec 时如何忽略大小写?

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

我应该使用什么选项以及在哪里指定它?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久随 2024-08-16 06:45:42

您需要将第二个参数中的 PCRE_CASELESS 传递给 pcre_compile,如下所示:(

pcre_compile(pattern, PCRE_CASELESS, ...

请注意,您在那里泄漏内存 - 您需要调用 pcre_free > 在 pcre_compile 返回的对象上。)

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

无边思念无边月 2024-08-16 06:45:42

您可以在 pcre_compile.h 文件中使用 PCRE_CASELESS 标志。

例子:

  pcre_compile(
    pattern,              /* the pattern */
    PCRE_CASELESS|PCRE_MULTILINE,                    /* default options */
    &error,               /* for error message */
    &erroffset,           /* for error offset */
    NULL);                /* use default character tables */

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 */
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文