Re: BUG #4044: Incorrect RegExp substring Output

Поиск
Список
Период
Сортировка
От Rui Martins
Тема Re: BUG #4044: Incorrect RegExp substring Output
Дата
Msg-id 3028.B1UHWUVdEF8=.1205941418.squirrel@www.pdmfc.com
обсуждение исходный текст
Ответ на Re: BUG #4044: Incorrect RegExp substring Output  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Hi Tom

What I meant is:

  SELECT '' ~ '^(something)?$'

This will match, i.e. the empty string will match with the expression,
and substring would return and empty string.

or in other words:
   it returns true

  SELECT SUBSTRING( '', '^(something)?$' )

This will also match, has a global expression, and the return is, has
expected, an EMPTY string !

Now, If all the above is correct (which I believe it is), than:

  SELECT 'TEST' ~ '^TEST(something)?$'

Will also return TRUE, which it correctly does.

So, what would you expect to be the result, from the following query ?

  SELECT SUBSTRING( 'TEST', '^TEST(something)?$' )

The current returned value is 'TEST' which is wrong!
This we knew already, from my bug Report.

But by analogy, with the previous queries, and to maintain overall
coherence the expected correct result should be and EMPTY string too!

But If I understood you correctly, you said that it will return a result
of NULL, which I think is incorrect.


Did I make my self clearer know ?

Thanks again for feedback.

See ya
   Rui Martins

> "Rui Martins" <Rui.Martins@PDMFC.com> writes:
>> Here the context of the word "match" may be misleading us, in this
>> conversation.
>> I say this, because in my report, the second substring expression, the
>> one
>> for RoomSize:
>
>> SUBSTRING( BedNo, '^[[:digit:]]+([a-zA-Z]*)(:[[:digit:]]+)?$' ) AS
>> RoomSize,
>
>> Actually returns an EMPTY String, and not a NULL, for the first 2 test
>> cases, which I believe is the correct answer.
>
> What's your point?  A zero-length substring is a legal match to that
> subexpression ... unlike the third one.
>
>             regards, tom lane
>

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

Предыдущее
От: "Rui Martins"
Дата:
Сообщение: Re: BUG #4044: Incorrect RegExp substring Output
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #4044: Incorrect RegExp substring Output