Re: Regexp matching: bug or operator error?

Поиск
Список
Период
Сортировка
От Thomas Hallgren
Тема Re: Regexp matching: bug or operator error?
Дата
Msg-id 41A3CAA6.7070100@mailblocks.com
обсуждение исходный текст
Ответ на Regexp matching: bug or operator error?  (Ken Tanzer <ktanzer@desc.org>)
Список pgsql-general
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

В списке pgsql-general по дате отправления:

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: Upcoming Changes to News Server ...
Следующее
От: Hunter Hillegas
Дата:
Сообщение: Copying into Unicode - Correcting Errors