Re: substring synopsis section, third argument is optional doc didn't show that - Mailing list pgsql-docs

From Tom Lane
Subject Re: substring synopsis section, third argument is optional doc didn't show that
Date
Msg-id 3354664.1737478404@sss.pgh.pa.us
Whole thread Raw
In response to substring synopsis section, third argument is optional doc didn't show that  (jian he <jian.universality@gmail.com>)
Responses Re: substring synopsis section, third argument is optional doc didn't show that
List pgsql-docs
jian he <jian.universality@gmail.com> writes:
> https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP

> """
> or as a plain three-argument function:
> substring(string, pattern, escape-character)
> """

> but here "escape-character" is optional.

> substring(string, pattern [,escape-character])
> would be more accurate.

No, the text is correct as written.  substring(text, text) is a
completely different function that implements POSIX regular
expressions, not SQL regular expressions.  It's described in
the next section (9.7.3).  For example,

regression=# select substring('foobar', 'o.b');
 substring
-----------
 oob
(1 row)

regression=# select substring('foobar', 'o.b', '');
 substring
-----------

(1 row)

because '.' is a metacharacter in POSIX but not SQL regexps.

            regards, tom lane



pgsql-docs by date:

Previous
From: PG Doc comments form
Date:
Subject: Request for Formal Syntax of WHERE Clause Conditions
Next
From: Tom Lane
Date:
Subject: Re: Request for Formal Syntax of WHERE Clause Conditions