Skip site navigation (1) Skip section navigation (2)

problem with non-greedy regex match

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: problem with non-greedy regex match
Date: 2009-01-13 19:39:11
Message-ID: b42b73150901131139v4106f749h2d493135e1528234@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugs
I _may_ have found a problem that is affecting non-greedy regex matches.

select regexp_matches(
  $$x = foo y x = foo y $$,
  $$x\s+(.*?)y$$  ,'g');

As I read it, this should match ' = foo' twice.  Instead, it matches
"= foo y x = foo " once.  The non-greedy form (.*?) should break out
at the first 'y'.

Interestingly, this works:
select regexp_matches(
  $$x = foo y x = foo y $$,
  $$x(.*?)y$$  ,'g');

It's the same regex minus the space after 'x'.

merlin

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2009-01-13 20:49:37
Subject: Re: problem with non-greedy regex match
Previous:From: Kevin GrittnerDate: 2009-01-13 19:03:16
Subject: Re: [BUGS] Status of issue 4593

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group