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

From David G. Johnston
Subject Re: add function argument names to regex* functions.
Date
Msg-id CAKFQuwZcJFkmuMHPKnsRhgCx3=WdtSS3T0D+WAEXA7PdYH4ZJg@mail.gmail.com
Whole thread Raw
In response to Re: add function argument names to regex* functions.  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: add function argument names to regex* functions.
List pgsql-hackers
On Wed, May 15, 2024 at 11:46 AM Robert Haas <robertmhaas@gmail.com> wrote:
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.


I think this confusion goes to show that replacing N with count doesn't work.

"replace_at" comes to mind as a better name.

By default, only the first match of the pattern is replaced.  If replace_at is specified and greater than zero, then the first "replace_at - 1" matches are skipped before making a single replacement (i.e., the g flag is ignored when replace_at is specified.)

David J.

pgsql-hackers by date:

Previous
From: Josef Šimánek
Date:
Subject: Re: [PATCH] Add --syntax to postgres for SQL syntax checking
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] Add --syntax to postgres for SQL syntax checking