Re: bug with RE

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: bug with RE
Дата
Msg-id 20070726080335.M12817@megazone.bigpanda.com
обсуждение исходный текст
Ответ на bug with RE  (Тучков Михаил<mtuchkov@ntrlab.ru>)
Список pgsql-bugs
On Thu, 26 Jul 2007, [UTF-8] =D0=A2=D1^C=D1^G=D0=BA=D0=BE=D0=B2 =D0^\=D0=B8=
=D1^E=D0=B0=D0=B8=D0=BB wrote:

> Please, help me!
> My code:
> "IF char_length(substring(str from '^[a-zA-Z]*://'))=3D0 THEN
>    str:=3D 'http://'||str;
> END IF;"
>
> If str=3D http://www.msn.com then nothing happen
> (all is OK), but if str=3D just www.msn.com then nothing happen too!
>
> Why?


According to:
 http://www.postgresql.org/docs/8.2/interactive/functions-matching.html
a non-match returns NULL, whose char_length is also NULL.

Using one of the regexp operators ~ or ~* would probably be easier, but if
you really wanted to do this with substring, you should be checking for no
match, not a 0 length match.

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

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: BUG #3487: regular exp
Следующее
От: Stephen Frost
Дата:
Сообщение: psql \COPY accepts multiple NULL AS