Re: add function argument names to regex* functions.

Jim Nasby <jim.nasby@gmail.com>

From: Jim Nasby <jim.nasby@gmail.com>
To: Dian Fay <di@nmfay.com>, jian he <jian.universality@gmail.com>, Peter Eisentraut <peter@eisentraut.org>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-01-03T22:23:37Z
Lists: pgsql-hackers

Attachments

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 1/1/24 12:05 PM, Dian Fay wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:CY3KI01TXYMD.3Q41WQ6U0NFEO@nmfay.com">
      <pre>I agree that the parameter name `n` is not ideal. For example, in
`regexp_replace` it's easy to misinterpret it as "make up to n
replacements". This has not been a problem when `n` only lives in the
documentation which explains exactly what it does, but that context is
not readily available in code expressing `n =&gt; 3`.
</pre>
    </blockquote>
    Agreed; IMO it's worth diverging from what Oracle has done here.<br>
    <blockquote type="cite"
      cite="mid:CY3KI01TXYMD.3Q41WQ6U0NFEO@nmfay.com">
      <pre>
Another possibility is `index`, which is relatively short and not a
reserved keyword ^1. `position` is not as precise but would avoid the
conceptual overloading of ordinary indices.
</pre>
    </blockquote>
    <p>I'm not a fan of "index" since that leaves the question of
      whether it's 0 or 1 based. "Position" is a bit better, but I think
      Jian's suggestion of "occurance" is best.<br>
    </p>
    <pre class="moz-signature" cols="72">--
Jim Nasby, Data Architect, Austin TX</pre>
  </body>
</html>



Commits

  1. Doc: fix text's description of regexp_replace's arguments.

  2. Add argument names to the regexp_XXX functions.

  3. Add assorted new regexp_xxx SQL functions.