【发布时间】:2017-02-08 04:17:04
【问题描述】:
在 Perl 中,我们可以做到这一点
s/pattern/func($1)/e
是否有任何方便的功能可以与 PCRE2 做同样的事情,比如
::pcre2_substitute_with_callback(
re, // the compiled pattern
pcuSubject, ccuSubject, // the subject and its length
PCRE2_SUBSTITUTE_GLOBAL, // the substitute options
matches,
NULL, // the match context
[](PCRE2_SPTR pcuMatched)->PCRE2_SPTR{ // the callback
return "replacement";
},
pcuResult, &ccuResult
);
谢谢。
【问题讨论】: