Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1taHVJ-000OND-2A for pgsql-docs@arkaria.postgresql.org; Tue, 21 Jan 2025 16:53:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1taHVI-001fuR-45 for pgsql-docs@arkaria.postgresql.org; Tue, 21 Jan 2025 16:53:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1taHVH-001fox-Qc for pgsql-docs@lists.postgresql.org; Tue, 21 Jan 2025 16:53:27 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1taHVF-000lFj-1q for pgsql-docs@lists.postgresql.org; Tue, 21 Jan 2025 16:53:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 50LGrOUX3354665; Tue, 21 Jan 2025 11:53:24 -0500 From: Tom Lane To: jian he cc: pgsql-docs@lists.postgresql.org Subject: Re: substring synopsis section, third argument is optional doc didn't show that In-reply-to: References: Comments: In-reply-to jian he message dated "Tue, 21 Jan 2025 16:00:21 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3354663.1737478404.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 21 Jan 2025 11:53:24 -0500 Message-ID: <3354664.1737478404@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > https://www.postgresql.org/docs/current/functions-matching.html#FUNCTION= S-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=3D# select substring('foobar', 'o.b'); substring = ----------- oob (1 row) regression=3D# select substring('foobar', 'o.b', ''); substring = ----------- = (1 row) because '.' is a metacharacter in POSIX but not SQL regexps. regards, tom lane