Ken Tanzer wrote:
> 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.
>
The regexp {1,5} is satisfied with the minimum of 1 digit. It looks
ahead and finds your '.*'. That in turn consumes all but the last character.
Perhaps what you want is '[^0-9]+([0-9]{1,5})[^0-9]+'
Translates to "at least one non digit followed by 1-5 digits and then at
least 1 non digit".
Regards,
Thomas Hallgren