Re: Regexp matching: bug or operator error?

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: Regexp matching: bug or operator error?
Дата
Msg-id
1713.1101254499@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
Regexp matching: bug or operator error? Ken Tanzer <ktanzer@desc.org>
Re: Regexp matching: bug or operator error? Tom Lane <tgl@sss.pgh.pa.us>
Re: Regexp matching: bug or operator error? Tom Lane <tgl@sss.pgh.pa.us>
Re: Regexp matching: bug or operator error? Ken Tanzer <ktanzer@desc.org>
Re: Regexp matching: bug or operator error? Tom Lane <tgl@sss.pgh.pa.us>
Re: Regexp matching: bug or operator error? Kenneth Tanzer <ktanzer@desc.org>
Re: Regexp matching: bug or operator error? Tom Lane <tgl@sss.pgh.pa.us>
Re: Regexp matching: bug or operator error? Tom Lane <tgl@sss.pgh.pa.us>
Re: Regexp matching: bug or operator error? Thomas Hallgren <thhal@mailblocks.com>
Ken Tanzer  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
В списке pgsql-general по дате отправления
От: Hunter Hillegas
Дата:
От: Tom Lane
Дата:
FAQ