如何使用libpcre2在纯文本文件中搜索子字符串?

时间:2019-05-28 16:56:55

标签: c grep pcre pcregrep

我想使用libpcre2来匹配纯文本文件中的子字符串,但是libpcre2不提供:pcre2_match_file()或pcre2_match_fd()API。看来我需要自己打开文件,然后逐行将其依次传递给pcre2_match()函数?

我不确定是否应该这样做。

除此之外,还有更高的性能方式吗?例如使用mmap()将文件映射到内存?

我只尝试匹配缓冲区,并且想扩展以匹配整个纯文本文件。

#include <pcre2.h>

int pcre2_match(const pcre2_code *code, PCRE2_SPTR subject, PCRE2_SIZE length, PCRE2_SIZE startoffset, uint32_t options, pcre2_match_data *match_data, pcre2_match_context *mcontext);

0 个答案:

没有答案