@@ -5377,15 +5377,15 @@ substring('foobar' similar '#"o_b#"%' escape '#') <lineannotation>NULL</linea
5377
5377
<indexterm>
5378
5378
<primary>substring</primary>
5379
5379
</indexterm>
5380
- <indexterm>
5381
- <primary>regexp_replace</primary>
5382
- </indexterm>
5383
5380
<indexterm>
5384
5381
<primary>regexp_match</primary>
5385
5382
</indexterm>
5386
5383
<indexterm>
5387
5384
<primary>regexp_matches</primary>
5388
5385
</indexterm>
5386
+ <indexterm>
5387
+ <primary>regexp_replace</primary>
5388
+ </indexterm>
5389
5389
<indexterm>
5390
5390
<primary>regexp_split_to_table</primary>
5391
5391
</indexterm>
@@ -5542,46 +5542,6 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
5542
5542
</programlisting>
5543
5543
</para>
5544
5544
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
-
5585
5545
<para>
5586
5546
The <function>regexp_match</function> function returns a text array of
5587
5547
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;
5684
5644
</para>
5685
5645
</tip>
5686
5646
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
+
5687
5687
<para>
5688
5688
The <function>regexp_split_to_table</function> function splits a string using a POSIX
5689
5689
regular expression pattern as a delimiter. It has the syntax
0 commit comments