1PCRE2_SUBSTITUTE(3)        Library Functions Manual        PCRE2_SUBSTITUTE(3)
2
3
4

NAME

6       PCRE2 - Perl-compatible regular expressions (revised API)
7

SYNOPSIS

9
10       #include <pcre2.h>
11
12       int pcre2_substitute(const pcre2_code *code, PCRE2_SPTR subject,
13         PCRE2_SIZE length, PCRE2_SIZE startoffset,
14         uint32_t options, pcre2_match_data *match_data,
15         pcre2_match_context *mcontext, PCRE2_SPTR replacement,
16         PCRE2_SIZE rlength, PCRE2_UCHAR *outputbuffer,
17         PCRE2_SIZE *outlengthptr);
18

DESCRIPTION

20
21       This  function  matches  a  compiled regular expression against a given
22       subject string, using a matching algorithm that is similar  to  Perl's.
23       It  then makes a copy of the subject, substituting a replacement string
24       for what was matched.  Its arguments are:
25
26         code          Points to the compiled pattern
27         subject       Points to the subject string
28         length        Length of the subject string
29         startoffset   Offset in the subject at which to start matching
30         options       Option bits
31         match_data    Points to a match data block, or is NULL
32         mcontext      Points to a match context, or is NULL
33         replacement   Points to the replacement string
34         rlength       Length of the replacement string
35         outputbuffer  Points to the output buffer
36         outlengthptr  Points to the length of the output buffer
37
38       A match context is needed only if you want to:
39
40         Set up a callout function
41         Change the limit for calling the internal function match()
42         Change the limit for calling match() recursively
43         Set custom memory management when the heap is used for recursion
44
45       The length, startoffset and rlength values are code units, not  characā€
46       ters,  as  is  the contents of the variable pointed at by outlengthptr,
47       which is updated to the actual length of the new string.   The  options
48       are:
49
50         PCRE2_ANCHORED             Match only at the first position
51         PCRE2_NOTBOL               Subject is not the beginning of a line
52         PCRE2_NOTEOL               Subject is not the end of a line
53         PCRE2_NOTEMPTY             An empty string is not a valid match
54         PCRE2_NOTEMPTY_ATSTART     An empty string at the start of the
55                                     subject is not a valid match
56         PCRE2_NO_UTF_CHECK         Do not check the subject or replacement
57                                     for UTF validity (only relevant if
58                                     PCRE2_UTF was set at compile time)
59         PCRE2_SUBSTITUTE_EXTENDED  Do extended replacement processing
60         PCRE2_SUBSTITUTE_GLOBAL    Replace all occurrences in the subject
61         PCRE2_SUBSTITUTE_OVERFLOW_LENGTH  If overflow, compute needed length
62         PCRE2_SUBSTITUTE_UNKNOWN_UNSET  Treat unknown group as unset
63         PCRE2_SUBSTITUTE_UNSET_EMPTY  Simple unset insert = empty string
64
65       The  function returns the number of substitutions, which may be zero if
66       there were no matches. The result can be greater  than  one  only  when
67       PCRE2_SUBSTITUTE_GLOBAL  is  set.  In the event of an error, a negative
68       error code is returned.
69
70       There is a complete description of the PCRE2 native API in the pcre2api
71       page and a description of the POSIX API in the pcre2posix page.
72
73
74
75PCRE2 10.21                    12 December 2015            PCRE2_SUBSTITUTE(3)
Impressum