X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 29EBA3A411C for ; Wed, 24 Nov 2004 00:01:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71089-01 for ; Wed, 24 Nov 2004 00:01:40 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 760863A3FE9 for ; Wed, 24 Nov 2004 00:01:41 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id iAO01dE2001714; Tue, 23 Nov 2004 19:01:39 -0500 (EST) To: Ken Tanzer Cc: pgsql-general@postgresql.org Subject: Re: Regexp matching: bug or operator error? In-reply-to: <41A3C6C6.2090605@desc.org> References: <41A3C6C6.2090605@desc.org> Comments: In-reply-to Ken Tanzer message dated "Tue, 23 Nov 2004 15:24:54 -0800" Date: Tue, 23 Nov 2004 19:01:39 -0500 Message-ID: <1713.1101254499@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/1144 X-Sequence-Number: 69224 Ken Tanzer writes: > Using Postgres V. 7.4.1, the following query: > SELECT substring('X12345X' FROM '.*?([0-9]{1,5}).*?'); > Returns '1'. I would expect it to return '12345'. Is this a bug, or am > I missing something? Thanks. Hmm ... playing with it, it seems that there may indeed be a bug here ... it's acting like the "non greedy" flag from the .*? is being applied to the {m,n} as well. In other words the behavior would be correct for SELECT substring('X12345X' FROM '.*?([0-9]{1,5}?).*?'); However, aren't you doing this the hard way? Why not just SELECT substring('X12345X' FROM '([0-9]{1,5})'); regards, tom lane