Re: BUG #4044: Incorrect RegExp substring Output

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #4044: Incorrect RegExp substring Output
Дата
Msg-id 17138.1205952974@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #4044: Incorrect RegExp substring Output  ("Rui Martins" <Rui.Martins@PDMFC.com>)
Ответы Re: BUG #4044: Incorrect RegExp substring Output
Список pgsql-bugs
"Rui Martins" <Rui.Martins@PDMFC.com> writes:
> Even though this can me though as argumentative, think about this expression:

> (something)?

> Will "match" with an empty string in the context of a full expression, and
> will return an EMPTY String. So by analogy, I would expect it, to return
> the same as a sub-expression when it actually has a "match" even if with
> an empty sub-string.

Uh, no, it *won't* match if there is not "something" in the string.

The behavior you are looking for is properly obtained this way:

    ((something)?)

This will return either "something" or an empty string (assuming
we have a globally successful match).  The point is there's a difference
between what X matches (or doesn't) and what X? matches.

            regards, tom lane

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