From: christian_maechler@hotmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present)
Date: Mon, 03 Aug 2015 22:44:50 +0000
Message-ID: <20150803224450.1115.8803@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 13538
Logged by: Chris Mächler
Email address: christian_maechler@hotmail.com
PostgreSQL version: 9.3.0
Operating system: ?
Description:
Here is an example to verify and reproduce the error (extract a number and
the things before and after it with 3 groups):
'(.*)([+-]?[0-9]*\.[0-9]+)(.*)'
Using regexü_matches this will produce an undesirable result (only one digit
in group 2), but everything behaves correctly, the third group matches until
the end.
'(.*?)([+-]?[0-9]*\.[0-9]+)(.*)'
If we change the first group to non-greedy to fix this, then the bug
appears: the third group becomes non-greedy too (it shouldn't!) and
therefore it is always empty instead of matching until the end of the line.
Also the first group is empty (should match from start!), it should find a
match at start position, whether it is non-greedy or not and not look ahead
if the non-greedy group can be reduced if starting to match at the next
index. Both are wrong behaviors.
(the workaround is anchoring, but the behavior of the regex is still wrong)
link: http://sqlfiddle.com/#!15/f0f14/14
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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
Subject: Re: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present)
In-Reply-To: <20150803224450.1115.8803@wrigleys.postgresql.org>
References: <20150803224450.1115.8803@wrigleys.postgresql.org>
* 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