pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christian Mächler <christian_maechler@hotmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present)
Date: Tue, 4 Aug 2015 17:39:47 +0200
Message-ID: <DUB128-W56A2C0B3D9D79B7D14F20EF8760@phx.gbl> (raw)
In-Reply-To: <26003.1438700337@sss.pgh.pa.us>
References: <20150803224450.1115.8803@wrigleys.postgresql.org>
	<CAKFQuwaXQvXx9OEDNXAA5eXdbP0CKBnWow+L0aoh1vH2J6LrtQ@mail.gmail.com>
	<DUB128-W2990BB7605238976ADE6AEF8760@phx.gbl>
	<26003.1438700337@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

You say it is okay that a greedy group suddenly becomes non-greedy if ANOTHER group is made non-greedy?

I've chosen a simple example, but I'm pretty sure I could construct several use-cases which can be solved easily if the regex behaves like in java, javaScript, perl etc.  but not with how it is done here. It's clearly not a feature. Already simple things like ending a match with any amount of numbers will become difficult if non-greedy groups are present, e.g. instead of ...([0-9]+) you will have to write ...([0-9]+)(?![0-9])  makes things easier...

Seriously I didn't want to start a debate whether this is right or wrong, because I honestly can't understand how anyone could defend the behavior mentioned in the first sentence of this message. As I said, I just wanted to point out that there is a bug to help improve, but if you prefer it like this it is fine with me, I just think then you probably haven't used regex that much.

Chris

> From: tgl@sss.pgh.pa.us
> To: christian_maechler@hotmail.com
> CC: david.g.johnston@gmail.com; pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present)
> Date: Tue, 4 Aug 2015 10:58:57 -0400
> 
> =?iso-8859-1?B?Q2hyaXN0aWFuIE3kY2hsZXI=?= <christian_maechler@hotmail.com> writes:
> > Here some more detailed examples to show why the behavior of the 3rd group is clearly wrong also according to the specification:
> 
> What specification are you reading?  The POSIX standard for regular
> expressions doesn't mention non-greedy quantifiers at all.
> 
> As David says, these examples appear to be following what's stated in
> http://www.postgresql.org/docs/9.4/static/functions-matching.html#POSIX-MATCHING-RULES
> The Spencer regex engine we use has a notion of greediness or
> non-greediness of the entire regex, and further that that takes precedence
> for determining the overall match length over greediness of individual
> subexpressions.  That behavior might be inconvenient for this particular
> use-case, but that doesn't make it a bug.
> 
> 			regards, tom lane
 		 	   		  =

view thread (10+ messages)  latest in thread

Message-ID: <DUB128-W56A2C0B3D9D79B7D14F20EF8760@phx.gbl>
Permalink:  ../DUB128-W56A2C0B3D9D79B7D14F20EF8760@phx.gbl/
Also on:    postgresql.org/message-id/DUB128-W56A2C0B3D9D79B7D14F20EF8760@phx.gbl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: christian_maechler@hotmail.com, tgl@sss.pgh.pa.us, david.g.johnston@gmail.com
  Subject: Re: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present)
  In-Reply-To: <DUB128-W56A2C0B3D9D79B7D14F20EF8760@phx.gbl>
  References: <20150803224450.1115.8803@wrigleys.postgresql.org> <CAKFQuwaXQvXx9OEDNXAA5eXdbP0CKBnWow+L0aoh1vH2J6LrtQ@mail.gmail.com> <DUB128-W2990BB7605238976ADE6AEF8760@phx.gbl> <26003.1438700337@sss.pgh.pa.us> <DUB128-W56A2C0B3D9D79B7D14F20EF8760@phx.gbl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox