1 .TH PCRE2_SUBSTITUTE 3 "04 April 2017" "PCRE2 10.30"
3 PCRE2 - Perl-compatible regular expressions (revised API)
10 .B int pcre2_substitute(const pcre2_code *\fIcode\fP, PCRE2_SPTR \fIsubject\fP,
11 .B " PCRE2_SIZE \fIlength\fP, PCRE2_SIZE \fIstartoffset\fP,"
12 .B " uint32_t \fIoptions\fP, pcre2_match_data *\fImatch_data\fP,"
13 .B " pcre2_match_context *\fImcontext\fP, PCRE2_SPTR \fIreplacement\fP,"
14 .B " PCRE2_SIZE \fIrlength\fP, PCRE2_UCHAR *\fIoutputbuffer\fP,"
15 .B " PCRE2_SIZE *\fIoutlengthptr\fP);"
21 This function matches a compiled regular expression against a given subject
22 string, using a matching algorithm that is similar to Perl's. It then makes a
23 copy of the subject, substituting a replacement string for what was matched.
26 \fIcode\fP Points to the compiled pattern
27 \fIsubject\fP Points to the subject string
28 \fIlength\fP Length of the subject string
29 \fIstartoffset\fP Offset in the subject at which to start matching
30 \fIoptions\fP Option bits
31 \fImatch_data\fP Points to a match data block, or is NULL
32 \fImcontext\fP Points to a match context, or is NULL
33 \fIreplacement\fP Points to the replacement string
34 \fIrlength\fP Length of the replacement string
35 \fIoutputbuffer\fP Points to the output buffer
36 \fIoutlengthptr\fP Points to the length of the output buffer
38 A match data block is needed only if you want to inspect the data from the
39 match that is returned in that block. A match context is needed only if you
42 Set up a callout function
43 Set a matching offset limit
44 Change the backtracking match limit
45 Change the backtracking depth limit
46 Set custom memory management in the match context
48 The \fIlength\fP, \fIstartoffset\fP and \fIrlength\fP values are code
49 units, not characters, as is the contents of the variable pointed at by
50 \fIoutlengthptr\fP, which is updated to the actual length of the new string.
51 The subject and replacement lengths can be given as PCRE2_ZERO_TERMINATED for
52 zero-terminated strings. The options are:
54 PCRE2_ANCHORED Match only at the first position
55 PCRE2_ENDANCHORED Pattern can match only at end of subject
56 PCRE2_NOTBOL Subject is not the beginning of a line
57 PCRE2_NOTEOL Subject is not the end of a line
58 PCRE2_NOTEMPTY An empty string is not a valid match
60 PCRE2_NOTEMPTY_ATSTART An empty string at the start of the
61 subject is not a valid match
62 PCRE2_NO_JIT Do not use JIT matching
64 PCRE2_NO_UTF_CHECK Do not check the subject or replacement
65 for UTF validity (only relevant if
66 PCRE2_UTF was set at compile time)
67 PCRE2_SUBSTITUTE_EXTENDED Do extended replacement processing
68 PCRE2_SUBSTITUTE_GLOBAL Replace all occurrences in the subject
69 PCRE2_SUBSTITUTE_OVERFLOW_LENGTH If overflow, compute needed length
70 PCRE2_SUBSTITUTE_UNKNOWN_UNSET Treat unknown group as unset
71 PCRE2_SUBSTITUTE_UNSET_EMPTY Simple unset insert = empty string
73 The function returns the number of substitutions, which may be zero if there
74 were no matches. The result can be greater than one only when
75 PCRE2_SUBSTITUTE_GLOBAL is set. In the event of an error, a negative error code
78 There is a complete description of the PCRE2 native API in the
82 page and a description of the POSIX API in the