【发布时间】:2022-12-14 23:43:29
【问题描述】:
我在我的 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,其余的将被视为字符串。
【问题讨论】: