【发布时间】:2016-02-28 15:18:07
【问题描述】:
我在我的 c++ 项目中使用pcre2_substitute() 函数来执行正则表达式替换:
int ret=pcre2_substitute(
re, /*Points to the compiled pattern*/
subject, /*Points to the subject string*/
subject_length, /*Length of the subject string*/
0, /*Offset in the subject at which to start matching*/
rplopts, /*Option bits*/
0, /*Points to a match data block, or is NULL*/
0, /*Points to a match context, or is NULL*/
replace, /*Points to the replacement string*/
replace_length, /*Length of the replacement string*/
output, /*Points to the output buffer*/
&outlengthptr /*Points to the length of the output buffer*/
);
This is the man page of the function。它没有说有多少捕获的组是可能的。我已经测试过$01、${6}、$12 可以工作,但限制是多少?
我检查了是否有像 C++ std::regex 这样的数字限制,但没有。 $000000000000001 与 $1 一样工作,而在 std::regex 中则意味着 $00,其余的将被视为字符串。
【问题讨论】: