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 data block is needed only if you want to inspect the data  from
39       the  match  that  is  returned in that block. A match context is needed
40       only if you want to:
41
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
47
48       The length, startoffset and rlength values are code units, not  characā€
49       ters,  as  is  the contents of the variable pointed at by outlengthptr,
50       which is updated to the actual length of the new string.   The  subject
51       and replacement lengths can be given as PCRE2_ZERO_TERMINATED for zero-
52       terminated strings. The options are:
53
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
59         PCRE2_NOTEMPTY_ATSTART     An empty string at the start of the
60                                     subject is not a valid match
61         PCRE2_NO_JIT               Do not use JIT matching
62         PCRE2_NO_UTF_CHECK         Do not check the subject or replacement
63                                     for UTF validity (only relevant if
64                                     PCRE2_UTF was set at compile time)
65         PCRE2_SUBSTITUTE_EXTENDED  Do extended replacement processing
66         PCRE2_SUBSTITUTE_GLOBAL    Replace all occurrences in the subject
67         PCRE2_SUBSTITUTE_OVERFLOW_LENGTH  If overflow, compute needed length
68         PCRE2_SUBSTITUTE_UNKNOWN_UNSET  Treat unknown group as unset
69         PCRE2_SUBSTITUTE_UNSET_EMPTY  Simple unset insert = empty string
70
71       The function returns the number of substitutions, which may be zero  if
72       there  were  no  matches.  The result can be greater than one only when
73       PCRE2_SUBSTITUTE_GLOBAL is set. In the event of an  error,  a  negative
74       error code is returned.
75
76       There is a complete description of the PCRE2 native API in the pcre2api
77       page and a description of the POSIX API in the pcre2posix page.
78
79
80
81PCRE2 10.30                      04 April 2017             PCRE2_SUBSTITUTE(3)
Impressum