re_replace/5 has Prolog code for doing the replacement. PCRE2 has support for replacement (I don't think this was in PCRE1), so it might make sense to use the PCRE2 code rather than the Prolog code - possibly the PCRE2 has features that aren't in the current code.
However, this would likely break compatibility, so might not be worth doing; especially as Prolog as DCGs, which are often more flexible (and even more efficient) than regexps.
re_replace/5
has Prolog code for doing the replacement. PCRE2 has support for replacement (I don't think this was in PCRE1), so it might make sense to use the PCRE2 code rather than the Prolog code - possibly the PCRE2 has features that aren't in the current code. However, this would likely break compatibility, so might not be worth doing; especially as Prolog as DCGs, which are often more flexible (and even more efficient) than regexps.