apr-utils apr_strmatch 正则表达式语法

发布于 2024-12-19 21:09:29 字数 474 浏览 3 评论 0原文

将以下正则表达式从 python: 移植

HASH_REGEX = re.compile("([a-fA-F0-9]{32})")
if HASH_REGEX.match(target):
    print "We have match"

我想使用apr-utils apr_strmatch 函数

pattern = apr_strmatch_precompile(pool, "([a-fA-F0-9]{32})", 0);
if (NULL != apr_strmatch(pattern, target, strlen(target)) {
    printf("We have match!\n");
}

到 C:问题是我不明白 apr-utils apr_strmatch 函数正在使用正则表达式(或方言)的语法。搜索文档和示例最终没有结果。

感谢您提前的建议...

I want to port the following regex from python:

HASH_REGEX = re.compile("([a-fA-F0-9]{32})")
if HASH_REGEX.match(target):
    print "We have match"

to C with apr-utils apr_strmatch function:

pattern = apr_strmatch_precompile(pool, "([a-fA-F0-9]{32})", 0);
if (NULL != apr_strmatch(pattern, target, strlen(target)) {
    printf("We have match!\n");
}

The problem is that I don't understand what syntax of regex (or dialect) apr-utils apr_strmatch function is using. Search for documentation and examples ended with no results.

Thanks for your advices in advance...

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

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

发布评论

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

评论(1

夜血缘 2024-12-26 21:09:29

apr_strmatch 根本不进行正则表达式匹配;它使用 Boyer–Moore–Horspool< 进行普通子字符串搜索/a> 算法(参见来源)。

对于 C 中的 RE 匹配,请尝试 PCRE

apr_strmatch doesn't do regular expression matching at all; it does ordinary substring search using the Boyer–Moore–Horspool algorithm (see source).

For RE matching in C, try PCRE.

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