Re: add function argument names to regex* functions.

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: add function argument names to regex* functions.
Дата
Msg-id CA+TgmoZYDN7BEQzpanKVvjEK48cn7Rq95_jjn=wTe2gM4-2J5w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: add function argument names to regex* functions.  (jian he <jian.universality@gmail.com>)
Ответы Re: add function argument names to regex* functions.  (Robert Haas <robertmhaas@gmail.com>)
Re: add function argument names to regex* functions.  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: add function argument names to regex* functions.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Fix PGresult leak in pg_dump during binary upgrade
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Fix PGresult leak in pg_dump during binary upgrade