@@ -5377,15 +5377,15 @@ substring('foobar' similar '#"o_b#"%' escape '#') <lineannotation>NULL</linea
53775377 <indexterm>
53785378 <primary>substring</primary>
53795379 </indexterm>
5380- <indexterm>
5381- <primary>regexp_replace</primary>
5382- </indexterm>
53835380 <indexterm>
53845381 <primary>regexp_match</primary>
53855382 </indexterm>
53865383 <indexterm>
53875384 <primary>regexp_matches</primary>
53885385 </indexterm>
5386+ <indexterm>
5387+ <primary>regexp_replace</primary>
5388+ </indexterm>
53895389 <indexterm>
53905390 <primary>regexp_split_to_table</primary>
53915391 </indexterm>
@@ -5542,46 +5542,6 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
55425542</programlisting>
55435543 </para>
55445544
5545- <para>
5546- The <function>regexp_replace</function> function provides substitution of
5547- new text for substrings that match POSIX regular expression patterns.
5548- It has the syntax
5549- <function>regexp_replace</function>(<replaceable>source</replaceable>,
5550- <replaceable>pattern</replaceable>, <replaceable>replacement</replaceable>
5551- <optional>, <replaceable>flags</replaceable> </optional>).
5552- The <replaceable>source</replaceable> string is returned unchanged if
5553- there is no match to the <replaceable>pattern</replaceable>. If there is a
5554- match, the <replaceable>source</replaceable> string is returned with the
5555- <replaceable>replacement</replaceable> string substituted for the matching
5556- substring. The <replaceable>replacement</replaceable> string can contain
5557- <literal>\</literal><replaceable>n</replaceable>, where <replaceable>n</replaceable> is 1
5558- through 9, to indicate that the source substring matching the
5559- <replaceable>n</replaceable>'th parenthesized subexpression of the pattern should be
5560- inserted, and it can contain <literal>\&</literal> to indicate that the
5561- substring matching the entire pattern should be inserted. Write
5562- <literal>\\</literal> if you need to put a literal backslash in the replacement
5563- text.
5564- The <replaceable>flags</replaceable> parameter is an optional text
5565- string containing zero or more single-letter flags that change the
5566- function's behavior. Flag <literal>i</literal> specifies case-insensitive
5567- matching, while flag <literal>g</literal> specifies replacement of each matching
5568- substring rather than only the first one. Supported flags (though
5569- not <literal>g</literal>) are
5570- described in <xref linkend="posix-embedded-options-table"/>.
5571- </para>
5572-
5573- <para>
5574- Some examples:
5575- <programlisting>
5576- regexp_replace('foobarbaz', 'b..', 'X')
5577- <lineannotation>fooXbaz</lineannotation>
5578- regexp_replace('foobarbaz', 'b..', 'X', 'g')
5579- <lineannotation>fooXX</lineannotation>
5580- regexp_replace('foobarbaz', 'b(..)', 'X\1Y', 'g')
5581- <lineannotation>fooXarYXazY</lineannotation>
5582- </programlisting>
5583- </para>
5584-
55855545 <para>
55865546 The <function>regexp_match</function> function returns a text array of
55875547 captured substring(s) resulting from the first match of a POSIX
@@ -5684,6 +5644,46 @@ SELECT col1, (SELECT regexp_matches(col2, '(bar)(beque)')) FROM tab;
56845644 </para>
56855645 </tip>
56865646
5647+ <para>
5648+ The <function>regexp_replace</function> function provides substitution of
5649+ new text for substrings that match POSIX regular expression patterns.
5650+ It has the syntax
5651+ <function>regexp_replace</function>(<replaceable>source</replaceable>,
5652+ <replaceable>pattern</replaceable>, <replaceable>replacement</replaceable>
5653+ <optional>, <replaceable>flags</replaceable> </optional>).
5654+ The <replaceable>source</replaceable> string is returned unchanged if
5655+ there is no match to the <replaceable>pattern</replaceable>. If there is a
5656+ match, the <replaceable>source</replaceable> string is returned with the
5657+ <replaceable>replacement</replaceable> string substituted for the matching
5658+ substring. The <replaceable>replacement</replaceable> string can contain
5659+ <literal>\</literal><replaceable>n</replaceable>, where <replaceable>n</replaceable> is 1
5660+ through 9, to indicate that the source substring matching the
5661+ <replaceable>n</replaceable>'th parenthesized subexpression of the pattern should be
5662+ inserted, and it can contain <literal>\&</literal> to indicate that the
5663+ substring matching the entire pattern should be inserted. Write
5664+ <literal>\\</literal> if you need to put a literal backslash in the replacement
5665+ text.
5666+ The <replaceable>flags</replaceable> parameter is an optional text
5667+ string containing zero or more single-letter flags that change the
5668+ function's behavior. Flag <literal>i</literal> specifies case-insensitive
5669+ matching, while flag <literal>g</literal> specifies replacement of each matching
5670+ substring rather than only the first one. Supported flags (though
5671+ not <literal>g</literal>) are
5672+ described in <xref linkend="posix-embedded-options-table"/>.
5673+ </para>
5674+
5675+ <para>
5676+ Some examples:
5677+ <programlisting>
5678+ regexp_replace('foobarbaz', 'b..', 'X')
5679+ <lineannotation>fooXbaz</lineannotation>
5680+ regexp_replace('foobarbaz', 'b..', 'X', 'g')
5681+ <lineannotation>fooXX</lineannotation>
5682+ regexp_replace('foobarbaz', 'b(..)', 'X\1Y', 'g')
5683+ <lineannotation>fooXarYXazY</lineannotation>
5684+ </programlisting>
5685+ </para>
5686+
56875687 <para>
56885688 The <function>regexp_split_to_table</function> function splits a string using a POSIX
56895689 regular expression pattern as a delimiter. It has the syntax
0 commit comments