我想从python中移植以下正则表达式:
HASH_REGEX = re.compile("([a-fA-F0-9]{32})")
if HASH_REGEX.match(target):
print "We have match"使用apr-utils apr_strmatch函数转换为C:
pattern = apr_strmatch_precompile(pool, "([a-fA-F0-9]{32})", 0);
if (NULL != apr_strmatch(pattern, target, strlen(target)) {
printf("We have match!\n");
}问题是我不理解正则表达式(或方言) apr-utils apr_strmatch函数使用的语法是什么。搜索文档和示例没有结果。
谢谢你提前给我的建议。
发布于 2011-12-06 18:42:09
apr_strmatch根本不执行正则表达式匹配;它使用Boyer–Moore–Horspool算法执行普通子字符串搜索(请参阅source)。
对于C中的RE匹配,请尝试PCRE。
https://stackoverflow.com/questions/8398210
复制相似问题