Ken Tanzer <ktanzer@desc.org> writes:
> Using Postgres V. 7.4.1, the following query:
> SELECT substring('X12345X' FROM '.*?([0-9]{1,5}).*?');
> Returns '1'. I would expect it to return '12345'. Is this a bug, or am
> I missing something? Thanks.
Hmm ... playing with it, it seems that there may indeed be a bug here
... it's acting like the "non greedy" flag from the .*? is being applied
to the {m,n} as well. In other words the behavior would be correct for
SELECT substring('X12345X' FROM '.*?([0-9]{1,5}?).*?');
However, aren't you doing this the hard way? Why not just
SELECT substring('X12345X' FROM '([0-9]{1,5})');
regards, tom lane