Re: bug with RE

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Тучков Михаил <mtuchkov(at)ntrlab(dot)ru>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: bug with RE
Date: 2007-07-26 15:08:51
Message-ID: 20070726080335.M12817@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


On Thu, 26 Jul 2007, [UTF-8] Т^C^Gков ^\и^Eаил wrote:

> Please, help me!
> My code:
> "IF char_length(substring(str from '^[a-zA-Z]*://'))=0 THEN
> str:= 'http://'||str;
> END IF;"
>
> If str= http://www.msn.com then nothing happen
> (all is OK), but if str= 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.

In response to

  • bug with RE at 2007-07-26 05:58:56 from Тучков Михаил

Browse pgsql-bugs by date

  From Date Subject
Next Message Stephen Frost 2007-07-27 04:50:28 psql \COPY accepts multiple NULL AS
Previous Message Magnus Hagander 2007-07-26 07:53:09 Re: BUG #3487: regular exp