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 1vGepx-003R0H-Kp for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Nov 2025 14:50:12 +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 1vGepw-0038CG-JK for pgsql-bugs@arkaria.postgresql.org; Wed, 05 Nov 2025 14:50:11 +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 1vGepw-0038C8-AH for pgsql-bugs@lists.postgresql.org; Wed, 05 Nov 2025 14:50:11 +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 1vGept-005bBb-1x for pgsql-bugs@lists.postgresql.org; Wed, 05 Nov 2025 14:50:10 +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 5A5Enuc2812835; Wed, 5 Nov 2025 09:49:56 -0500 From: Tom Lane To: zoulx1982@163.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19104: Does regexp_substr function support non-greedy matching? In-reply-to: <19104-c9e08a2693264d98@postgresql.org> References: <19104-c9e08a2693264d98@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 05 Nov 2025 12:41:30 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <812833.1762354196.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 05 Nov 2025 09:49:56 -0500 Message-ID: <812834.1762354196@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > When i use regexp_substr to process some text file, i found regexp_subst= r > does not support non-greedy match. Sure it does. But the details of the behavior are different from Perl's engine in cases where you have both greedy and non-greedy quantifiers (as your example does). Read the greediness rules here: https://www.postgresql.org/docs/current/functions-matching.html#POSIX-MATC= HING-RULES regards, tom lane