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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-bugs by date

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