Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

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: Thu, 26 Jul 2007 08:08:51 -0700 (PDT)
  • Message-id: <20070726080335.M12817@megazone.bigpanda.com> <text/plain>

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.



  • References:
    • bug with RE
      • From: Тучков Михаил

Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group