本文介绍了pcre 匹配 C 中的所有组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 PCRE C 库递归匹配一个组.
I want to match a group recursively using PCRE C library.
例如
pattern = "(\d,)"
subject = "5,6,3,2,"
OVECCOUNT = 30
pcrePtr = pcre_compile(pattern, 0, &error, &erroffset, NULL);
rc = pcre_exec(pcrePtr, NULL, subject, (int)strlen(subject),
0, 0, ovector, OVECCOUNT);
rc 为 -1..
如何匹配所有组,使得匹配的是5,", 6,", 3,", 2,"
How to match all groups so that matches are "5,", "6,", "3,", "2,"
以此类推,PHP 的 preg_match_all
会解析整个字符串,直到主题结束...
For analogy, PHP's preg_match_all
parses entire string until the end of subject...
推荐答案
我使用 strtok 的任何方式,因为 "," 在每组之后重复..
Any way I used strtok since "," was repeating after each group..
欢迎使用 pcre 的解决方案....
Solution using pcre is welcomed....
这篇关于pcre 匹配 C 中的所有组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!