Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion doc/html/pcre2api.html
Original file line number Diff line number Diff line change
Expand Up @@ -3742,7 +3742,8 @@ <h2><a name="SEC37" href="#TOC1">CREATING A NEW STRING WITH SUBSTITUTIONS</a></h
end before it starts are not supported, and give rise to an error return. For
global replacements, matches in which \K in a lookbehind causes the match to
start earlier than the point that was reached in the previous iteration are
also not supported.
also not supported. (These cases are only possible if the pattern was compiled
with the backwards-compatibility option PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK.)
</p>
<p>
The first seven arguments of <b>pcre2_substitute()</b> are the same as for
Expand Down Expand Up @@ -3875,6 +3876,18 @@ <h2><a name="SEC37" href="#TOC1">CREATING A NEW STRING WITH SUBSTITUTIONS</a></h
set in the match context, searching stops when that limit is reached.
</p>
<p>
Because global substitutions apply the pattern repeatedly to the subject string,
and always iterate over non-overlapping matches, the substitutions done by
<b>pcre2_substitute()</b> do not match and substitute text inside the replacement
strings themselves (no recursive/iterative substitution). However, applications
can easily implement other alternative replacement strategies, such as
iteratively replacing, then matching and replacing on the result. The
replacement loop inside <b>pcre2_substitute()</b> is simple and can be emulated
in client code by allocating a buffer, searching for matches in a loop, and
calling <b>pcre2_substitute()</b> with PCRE2_SUBSTITUTE_REPLACEMENT_ONLY an
PCRE2_SUBSTITUTE_MATCHED, and without PCRE2_SUBSTITUTE_GLOBAL.
</p>
<p>
You can restrict the effect of a global substitution to a portion of the
subject string by setting either or both of <i>startoffset</i> and an offset
limit. Here is a <b>pcre2test</b> example:
Expand Down
Loading