Documentation update and another cunning test pattern.
This commit is contained in:
parent
5ba5230b82
commit
03720de840
|
@ -48,8 +48,8 @@ Its arguments are:
|
||||||
<i>outlengthptr</i> Points to the length of the output buffer
|
<i>outlengthptr</i> Points to the length of the output buffer
|
||||||
</pre>
|
</pre>
|
||||||
A match data block is needed only if you want to inspect the data from the
|
A match data block is needed only if you want to inspect the data from the
|
||||||
match that is returned in that block or if PCRE2_SUBSTITUTE_MATCHED is set. A
|
final match that is returned in that block or if PCRE2_SUBSTITUTE_MATCHED is
|
||||||
match context is needed only if you want to:
|
set. A match context is needed only if you want to:
|
||||||
<pre>
|
<pre>
|
||||||
Set up a callout function
|
Set up a callout function
|
||||||
Set a matching offset limit
|
Set a matching offset limit
|
||||||
|
@ -57,9 +57,14 @@ match context is needed only if you want to:
|
||||||
Change the backtracking depth limit
|
Change the backtracking depth limit
|
||||||
Set custom memory management in the match context
|
Set custom memory management in the match context
|
||||||
</pre>
|
</pre>
|
||||||
The <i>length</i>, <i>startoffset</i> and <i>rlength</i> values are code
|
The <i>length</i>, <i>startoffset</i> and <i>rlength</i> values are code units,
|
||||||
units, not characters, as is the contents of the variable pointed at by
|
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.
|
<i>outlengthptr</i>. This variable must contain the length of the output buffer
|
||||||
|
when the function is called. If the function is successful, the value is
|
||||||
|
changed to the length of the new string, excluding the trailing zero that is
|
||||||
|
automatically added.
|
||||||
|
</P>
|
||||||
|
<P>
|
||||||
The subject and replacement lengths can be given as PCRE2_ZERO_TERMINATED for
|
The subject and replacement lengths can be given as PCRE2_ZERO_TERMINATED for
|
||||||
zero-terminated strings. The options are:
|
zero-terminated strings. The options are:
|
||||||
<pre>
|
<pre>
|
||||||
|
@ -74,16 +79,21 @@ zero-terminated strings. The options are:
|
||||||
PCRE2_UTF was set at compile time)
|
PCRE2_UTF was set at compile time)
|
||||||
PCRE2_SUBSTITUTE_EXTENDED Do extended replacement processing
|
PCRE2_SUBSTITUTE_EXTENDED Do extended replacement processing
|
||||||
PCRE2_SUBSTITUTE_GLOBAL Replace all occurrences in the subject
|
PCRE2_SUBSTITUTE_GLOBAL Replace all occurrences in the subject
|
||||||
PCRE2_SUBSTITUTE_LITERAL The replacement string is literal
|
PCRE2_SUBSTITUTE_LITERAL The replacement string is literal
|
||||||
PCRE2_SUBSTITUTE_MATCHED Use pre-existing match data for 1st match
|
PCRE2_SUBSTITUTE_MATCHED Use pre-existing match data for 1st match
|
||||||
PCRE2_SUBSTITUTE_OVERFLOW_LENGTH If overflow, compute needed length
|
PCRE2_SUBSTITUTE_OVERFLOW_LENGTH If overflow, compute needed length
|
||||||
PCRE2_SUBSTITUTE_UNKNOWN_UNSET Treat unknown group as unset
|
PCRE2_SUBSTITUTE_UNKNOWN_UNSET Treat unknown group as unset
|
||||||
PCRE2_SUBSTITUTE_UNSET_EMPTY Simple unset insert = empty string
|
PCRE2_SUBSTITUTE_UNSET_EMPTY Simple unset insert = empty string
|
||||||
</pre>
|
</pre>
|
||||||
If PCRE2_SUBSTITUTE_LITERAL is set, PCRE2_SUBSTITUTE_EXTENDED,
|
If PCRE2_SUBSTITUTE_LITERAL is set, PCRE2_SUBSTITUTE_EXTENDED,
|
||||||
PCRE2_SUBSTITUTE_UNKNOWN_UNSET, and PCRE2_SUBSTITUTE_UNSET_EMPTY are ignored.
|
PCRE2_SUBSTITUTE_UNKNOWN_UNSET, and PCRE2_SUBSTITUTE_UNSET_EMPTY are ignored.
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
|
If PCRE2_SUBSTITUTE_MATCHED is set, <i>match_data</i> must be non-zero; its
|
||||||
|
contents must be the result of a call to <b>pcre2_match()</b> using the same
|
||||||
|
pattern and subject.
|
||||||
|
</P>
|
||||||
|
<P>
|
||||||
The function returns the number of substitutions, which may be zero if there
|
The function returns the number of substitutions, which may be zero if there
|
||||||
are no matches. The result may be greater than one only when
|
are no matches. The result may be greater than one only when
|
||||||
PCRE2_SUBSTITUTE_GLOBAL is set. In the event of an error, a negative error code
|
PCRE2_SUBSTITUTE_GLOBAL is set. In the event of an error, a negative error code
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.TH PCRE2_SUBSTITUTE 3 "27 December 2019" "PCRE2 10.35"
|
.TH PCRE2_SUBSTITUTE 3 "05 January 2020" "PCRE2 10.35"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
PCRE2 - Perl-compatible regular expressions (revised API)
|
PCRE2 - Perl-compatible regular expressions (revised API)
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -36,8 +36,8 @@ Its arguments are:
|
||||||
\fIoutlengthptr\fP Points to the length of the output buffer
|
\fIoutlengthptr\fP Points to the length of the output buffer
|
||||||
.sp
|
.sp
|
||||||
A match data block is needed only if you want to inspect the data from the
|
A match data block is needed only if you want to inspect the data from the
|
||||||
match that is returned in that block or if PCRE2_SUBSTITUTE_MATCHED is set. A
|
final match that is returned in that block or if PCRE2_SUBSTITUTE_MATCHED is
|
||||||
match context is needed only if you want to:
|
set. A match context is needed only if you want to:
|
||||||
.sp
|
.sp
|
||||||
Set up a callout function
|
Set up a callout function
|
||||||
Set a matching offset limit
|
Set a matching offset limit
|
||||||
|
@ -45,9 +45,13 @@ match context is needed only if you want to:
|
||||||
Change the backtracking depth limit
|
Change the backtracking depth limit
|
||||||
Set custom memory management in the match context
|
Set custom memory management in the match context
|
||||||
.sp
|
.sp
|
||||||
The \fIlength\fP, \fIstartoffset\fP and \fIrlength\fP values are code
|
The \fIlength\fP, \fIstartoffset\fP and \fIrlength\fP values are code units,
|
||||||
units, not characters, as is the contents of the variable pointed at by
|
not characters, as is the contents of the variable pointed at by
|
||||||
\fIoutlengthptr\fP, which is updated to the actual length of the new string.
|
\fIoutlengthptr\fP. This variable must contain the length of the output buffer
|
||||||
|
when the function is called. If the function is successful, the value is
|
||||||
|
changed to the length of the new string, excluding the trailing zero that is
|
||||||
|
automatically added.
|
||||||
|
.P
|
||||||
The subject and replacement lengths can be given as PCRE2_ZERO_TERMINATED for
|
The subject and replacement lengths can be given as PCRE2_ZERO_TERMINATED for
|
||||||
zero-terminated strings. The options are:
|
zero-terminated strings. The options are:
|
||||||
.sp
|
.sp
|
||||||
|
@ -66,15 +70,19 @@ zero-terminated strings. The options are:
|
||||||
PCRE2_UTF was set at compile time)
|
PCRE2_UTF was set at compile time)
|
||||||
PCRE2_SUBSTITUTE_EXTENDED Do extended replacement processing
|
PCRE2_SUBSTITUTE_EXTENDED Do extended replacement processing
|
||||||
PCRE2_SUBSTITUTE_GLOBAL Replace all occurrences in the subject
|
PCRE2_SUBSTITUTE_GLOBAL Replace all occurrences in the subject
|
||||||
PCRE2_SUBSTITUTE_LITERAL The replacement string is literal
|
PCRE2_SUBSTITUTE_LITERAL The replacement string is literal
|
||||||
PCRE2_SUBSTITUTE_MATCHED Use pre-existing match data for 1st match
|
PCRE2_SUBSTITUTE_MATCHED Use pre-existing match data for 1st match
|
||||||
PCRE2_SUBSTITUTE_OVERFLOW_LENGTH If overflow, compute needed length
|
PCRE2_SUBSTITUTE_OVERFLOW_LENGTH If overflow, compute needed length
|
||||||
PCRE2_SUBSTITUTE_UNKNOWN_UNSET Treat unknown group as unset
|
PCRE2_SUBSTITUTE_UNKNOWN_UNSET Treat unknown group as unset
|
||||||
PCRE2_SUBSTITUTE_UNSET_EMPTY Simple unset insert = empty string
|
PCRE2_SUBSTITUTE_UNSET_EMPTY Simple unset insert = empty string
|
||||||
.sp
|
.sp
|
||||||
If PCRE2_SUBSTITUTE_LITERAL is set, PCRE2_SUBSTITUTE_EXTENDED,
|
If PCRE2_SUBSTITUTE_LITERAL is set, PCRE2_SUBSTITUTE_EXTENDED,
|
||||||
PCRE2_SUBSTITUTE_UNKNOWN_UNSET, and PCRE2_SUBSTITUTE_UNSET_EMPTY are ignored.
|
PCRE2_SUBSTITUTE_UNKNOWN_UNSET, and PCRE2_SUBSTITUTE_UNSET_EMPTY are ignored.
|
||||||
.P
|
.P
|
||||||
|
If PCRE2_SUBSTITUTE_MATCHED is set, \fImatch_data\fP must be non-zero; its
|
||||||
|
contents must be the result of a call to \fBpcre2_match()\fP using the same
|
||||||
|
pattern and subject.
|
||||||
|
.P
|
||||||
The function returns the number of substitutions, which may be zero if there
|
The function returns the number of substitutions, which may be zero if there
|
||||||
are no matches. The result may be greater than one only when
|
are no matches. The result may be greater than one only when
|
||||||
PCRE2_SUBSTITUTE_GLOBAL is set. In the event of an error, a negative error code
|
PCRE2_SUBSTITUTE_GLOBAL is set. In the event of an error, a negative error code
|
||||||
|
|
|
@ -6402,4 +6402,13 @@ ef) x/x,mark
|
||||||
Hackdaws love my big sphinx of quartz.
|
Hackdaws love my big sphinx of quartz.
|
||||||
Pack my fox with five dozen liquor jugs.
|
Pack my fox with five dozen liquor jugs.
|
||||||
|
|
||||||
|
/^(?>.*?([A-Z])(?!.*\1)){26}/i
|
||||||
|
The quick brown fox jumps over the lazy dog.
|
||||||
|
Jackdaws love my big sphinx of quartz.
|
||||||
|
Pack my box with five dozen liquor jugs.
|
||||||
|
\= Expect no match
|
||||||
|
The quick brown fox jumps over the lazy cat.
|
||||||
|
Hackdaws love my big sphinx of quartz.
|
||||||
|
Pack my fox with five dozen liquor jugs.
|
||||||
|
|
||||||
# End of testinput1
|
# End of testinput1
|
||||||
|
|
|
@ -10147,4 +10147,22 @@ No match
|
||||||
Pack my fox with five dozen liquor jugs.
|
Pack my fox with five dozen liquor jugs.
|
||||||
No match
|
No match
|
||||||
|
|
||||||
|
/^(?>.*?([A-Z])(?!.*\1)){26}/i
|
||||||
|
The quick brown fox jumps over the lazy dog.
|
||||||
|
0: The quick brown fox jumps over the lazy dog
|
||||||
|
1: g
|
||||||
|
Jackdaws love my big sphinx of quartz.
|
||||||
|
0: Jackdaws love my big sphinx of quartz
|
||||||
|
1: z
|
||||||
|
Pack my box with five dozen liquor jugs.
|
||||||
|
0: Pack my box with five dozen liquor jugs
|
||||||
|
1: s
|
||||||
|
\= Expect no match
|
||||||
|
The quick brown fox jumps over the lazy cat.
|
||||||
|
No match
|
||||||
|
Hackdaws love my big sphinx of quartz.
|
||||||
|
No match
|
||||||
|
Pack my fox with five dozen liquor jugs.
|
||||||
|
No match
|
||||||
|
|
||||||
# End of testinput1
|
# End of testinput1
|
||||||
|
|
Loading…
Reference in New Issue