119 lines
6.7 KiB
HTML
119 lines
6.7 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of PCRE2_SUBSTITUTE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>PCRE2_SUBSTITUTE</H1>
|
|
Section: C Library Functions (3)<BR>Updated: 04 April 2017<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
PCRE2 - Perl-compatible regular expressions (revised API)
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
<P>
|
|
<B>#include <<A HREF="file:///usr/include/pcre2.h">pcre2.h</A>></B>
|
|
|
|
<P>
|
|
|
|
<PRE>
|
|
<B>int pcre2_substitute(const pcre2_code *</B><I>code</I>, PCRE2_SPTR <I>subject</I>,
|
|
<B> PCRE2_SIZE </B><I>length</I>, PCRE2_SIZE <I>startoffset</I>,
|
|
<B> uint32_t </B><I>options</I>, pcre2_match_data *<I>match_data</I>,
|
|
<B> pcre2_match_context *</B><I>mcontext</I>, PCRE2_SPTR <I>replacement</I>,
|
|
<B> PCRE2_SIZE </B><I>rlength</I>, PCRE2_UCHAR *<I>outputbuffer</I>,
|
|
<B> PCRE2_SIZE *</B><I>outlengthptr</I>);
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
<P>
|
|
This function matches a compiled regular expression against a given subject
|
|
string, using a matching algorithm that is similar to Perl's. It then makes a
|
|
copy of the subject, substituting a replacement string for what was matched.
|
|
Its arguments are:
|
|
<P>
|
|
<BR> <I>code</I> Points to the compiled pattern
|
|
<BR> <I>subject</I> Points to the subject string
|
|
<BR> <I>length</I> Length of the subject string
|
|
<BR> <I>startoffset</I> Offset in the subject at which to start matching
|
|
<BR> <I>options</I> Option bits
|
|
<BR> <I>match_data</I> Points to a match data block, or is NULL
|
|
<BR> <I>mcontext</I> Points to a match context, or is NULL
|
|
<BR> <I>replacement</I> Points to the replacement string
|
|
<BR> <I>rlength</I> Length of the replacement string
|
|
<BR> <I>outputbuffer</I> Points to the output buffer
|
|
<BR> <I>outlengthptr</I> Points to the length of the output buffer
|
|
<P>
|
|
A match data block is needed only if you want to inspect the data from the
|
|
match that is returned in that block. A match context is needed only if you
|
|
want to:
|
|
<P>
|
|
<BR> Set up a callout function
|
|
<BR> Set a matching offset limit
|
|
<BR> Change the backtracking match limit
|
|
<BR> Change the backtracking depth limit
|
|
<BR> Set custom memory management in the match context
|
|
<P>
|
|
The <I>length</I>, <I>startoffset</I> and <I>rlength</I> values are code
|
|
units, not characters, as is the contents of the variable pointed at by
|
|
<I>outlengthptr</I>, which is updated to the actual length of the new string.
|
|
The subject and replacement lengths can be given as PCRE2_ZERO_TERMINATED for
|
|
zero-terminated strings. The options are:
|
|
<P>
|
|
<BR> PCRE2_ANCHORED Match only at the first position
|
|
<BR> PCRE2_ENDANCHORED Pattern can match only at end of subject
|
|
<BR> PCRE2_NOTBOL Subject is not the beginning of a line
|
|
<BR> PCRE2_NOTEOL Subject is not the end of a line
|
|
<BR> PCRE2_NOTEMPTY An empty string is not a valid match
|
|
|
|
<BR> PCRE2_NOTEMPTY_ATSTART An empty string at the start of the
|
|
<BR> subject is not a valid match
|
|
<BR> PCRE2_NO_JIT Do not use JIT matching
|
|
|
|
<BR> PCRE2_NO_UTF_CHECK Do not check the subject or replacement
|
|
<BR> for UTF validity (only relevant if
|
|
<BR> PCRE2_UTF was set at compile time)
|
|
<BR> PCRE2_SUBSTITUTE_EXTENDED Do extended replacement processing
|
|
<BR> PCRE2_SUBSTITUTE_GLOBAL Replace all occurrences in the subject
|
|
<BR> PCRE2_SUBSTITUTE_OVERFLOW_LENGTH If overflow, compute needed length
|
|
<BR> PCRE2_SUBSTITUTE_UNKNOWN_UNSET Treat unknown group as unset
|
|
<BR> PCRE2_SUBSTITUTE_UNSET_EMPTY Simple unset insert = empty string
|
|
<P>
|
|
The function returns the number of substitutions, which may be zero if there
|
|
were no matches. The result can be greater than one only when
|
|
PCRE2_SUBSTITUTE_GLOBAL is set. In the event of an error, a negative error code
|
|
is returned.
|
|
<P>
|
|
|
|
There is a complete description of the PCRE2 native API in the
|
|
|
|
<B>pcre2api</B>
|
|
|
|
page and a description of the POSIX API in the
|
|
|
|
<B>pcre2posix</B>
|
|
|
|
page.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:51 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|