Re: add function argument names to regex* functions. - Mailing list pgsql-hackers

From Robert Haas
Subject Re: add function argument names to regex* functions.
Date
Msg-id CA+TgmoZYDN7BEQzpanKVvjEK48cn7Rq95_jjn=wTe2gM4-2J5w@mail.gmail.com
Whole thread Raw
In response to Re: add function argument names to regex* functions.  (jian he <jian.universality@gmail.com>)
Responses Re: add function argument names to regex* functions.
Re: add function argument names to regex* functions.
Re: add function argument names to regex* functions.
List pgsql-hackers
On Thu, Apr 4, 2024 at 9:55 AM jian he <jian.universality@gmail.com> wrote:
> in the regexp_replace explanation section.
> changing "N" to lower-case would be misleading for regexp_replace?
> so I choose "count".

I don't see why that would be confusing for regexp_replace
specifically, but I think N => count is a reasonable change to make.
However, I don't think this quite works:

+     then the <replaceable>count</replaceable>'th match of the pattern

An English speaker is more likely to understand what is meant by
"N'th" than what is meant by "count'th". Even if they can guess, it's
kinda strange-looking. I think it needs to be rephrased somehow, but
I'm not sure exactly how.

> By the way, I think the above  is so hard to comprehend.
> I can only find related test in src/test/regress/sql/strings.sql are:
> SELECT regexp_replace('1112223333', E'(\\d{3})(\\d{3})(\\d{4})',
> E'(\\1) \\2-\\3');
> SELECT regexp_replace('foobarrbazz', E'(.)\\1', E'X\\&Y', 'g');
> SELECT regexp_replace('foobarrbazz', E'(.)\\1', E'X\\\\Y', 'g');
>
> but these tests seem not friendly.
> maybe we should have some simple examples to demonstrate the above paragraph.

Examples in the regression tests aren't meant as tests, not examples
for users to copy. If we want examples, those belong in the
documentation. However, I see that regexp_replace already has some
examples at https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-POSIX-REGEXP
so I'm not sure exactly what you think should be added.

--
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Fix PGresult leak in pg_dump during binary upgrade
Next
From: Tom Lane
Date:
Subject: Re: Fix PGresult leak in pg_dump during binary upgrade