On Fri, Jul 26, 2024 at 10:40 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > > jian he <jian.universal...@gmail.com> writes: > > On Fri, Jul 26, 2024 at 10:17 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > >> AFAICS, that one is correct, so I left it alone. (I didn't try to > >> merge the table's two entries into one like that, though.) > > > regexp_replace(string, pattern, replacement [, start [, N ]] [, flags ]). > > > can represent > > > regexp_replace(string, pattern, replacement , start, flags ) ? > > Hmm, yeah, you're right. I didn't want to write two separate > synopses there, but maybe there's no choice. >
we can get rid of: (Notice that <replaceable>N</replaceable> cannot be specified unless <replaceable>start</replaceable> is, but <replaceable>flags</replaceable> can be given in any case.) Now the output is It has the syntax regexp_replace(string, pattern, replacement [, flags ]) and regexp_replace(string, pattern, replacement, start [, N [, flags ]]). I also decorated "[]" with "<optional>".
From 40382d09208dc27fae141ffbfb181df649af7940 Mon Sep 17 00:00:00 2001 From: jian he <jian.universal...@gmail.com> Date: Sat, 27 Jul 2024 08:46:21 +0800 Subject: [PATCH v1 1/1] refactor regexp_replace syntax the status quo syntax: "It has the syntax regexp_replace(string, pattern, replacement [, start [, N ]] [, flags ])." is incorrect. changing it to "It has the syntax regexp_replace(string, pattern, replacement [, flags ]) and regexp_replace(string, pattern, replacement, start [, N [, flags ]])." --- doc/src/sgml/func.sgml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index b669ab7f..0fef7600 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -3426,7 +3426,7 @@ SELECT NOT(ROW(table.*) IS NOT NULL) FROM TABLE; -- detect at least one null in <primary>regexp_replace</primary> </indexterm> <function>regexp_replace</function> ( <parameter>string</parameter> <type>text</type>, <parameter>pattern</parameter> <type>text</type>, <parameter>replacement</parameter> <type>text</type> - [, <parameter>flags</parameter> <type>text</type> ] ) + <optional>, <parameter>flags</parameter> <type>text</type> </optional> ) <returnvalue>text</returnvalue> </para> <para> @@ -3445,8 +3445,8 @@ SELECT NOT(ROW(table.*) IS NOT NULL) FROM TABLE; -- detect at least one null in <entry role="func_table_entry"><para role="func_signature"> <function>regexp_replace</function> ( <parameter>string</parameter> <type>text</type>, <parameter>pattern</parameter> <type>text</type>, <parameter>replacement</parameter> <type>text</type>, <parameter>start</parameter> <type>integer</type> - [, <parameter>N</parameter> <type>integer</type> - [, <parameter>flags</parameter> <type>text</type> ] ] ) + <optional>, <parameter>N</parameter> <type>integer</type> + <optional>, <parameter>flags</parameter> <type>text</type> </optional> </optional> ) <returnvalue>text</returnvalue> </para> <para> @@ -6117,13 +6117,13 @@ SELECT col1, (SELECT regexp_matches(col2, '(bar)(beque)')) FROM tab; It has the syntax <function>regexp_replace</function>(<replaceable>string</replaceable>, <replaceable>pattern</replaceable>, <replaceable>replacement</replaceable> - <optional>, <replaceable>start</replaceable> + <optional>, <replaceable>flags</replaceable> </optional>) + and + <function>regexp_replace</function>(<replaceable>string</replaceable>, + <replaceable>pattern</replaceable>, <replaceable>replacement</replaceable>, + <replaceable>start</replaceable> <optional>, <replaceable>N</replaceable> - </optional></optional> - <optional>, <replaceable>flags</replaceable> </optional>). - (Notice that <replaceable>N</replaceable> cannot be specified - unless <replaceable>start</replaceable> is, - but <replaceable>flags</replaceable> can be given in any case.) + <optional>, <replaceable>flags</replaceable> </optional></optional>). The source <replaceable>string</replaceable> is returned unchanged if there is no match to the <replaceable>pattern</replaceable>. If there is a match, the <replaceable>string</replaceable> is returned with the -- 2.34.1