problem with non-greedy regex match - Mailing list pgsql-bugs

From Merlin Moncure
Subject problem with non-greedy regex match
Date
Msg-id b42b73150901131139v4106f749h2d493135e1528234@mail.gmail.com
Whole thread Raw
Responses Re: problem with non-greedy regex match
List 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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4613: intarray_del_elem returns an invalid empty array (for nullif comparison)
Next
From: Tom Lane
Date:
Subject: Re: problem with non-greedy regex match