someone please explain this regex behaviour - Mailing list pgsql-general

From Martin Leja
Subject someone please explain this regex behaviour
Date
Msg-id 4.3.2.7.2.20010127235532.02bd90d8@vmax.unix-ag.uni-siegen.de
Whole thread Raw
Responses Re: someone please explain this regex behaviour
List pgsql-general
Hi,

consider the following simple example, where i want to select a path by
using a where clause with the case insensitive operator "~*". Everything is
ok where i get a result of one row, but i don't understand the results with
0 rows:

backup=> select version();
version
-------------------------------------------------------------
PostgreSQL 6.5.3 on i686-pc-linux-gnu, compiled by gcc 2.95.2
(1 row)

backup=> create table foo (path varchar(300));
CREATE
backup=> insert into foo (path) values ('/My');
INSERT 29400 1
backup=> select path from foo where path ~* '/My';
path
----
/My
(1 row)

backup=> select path from foo where path ~* '^/My';
path
----
/My
(1 row)

backup=> select path from foo where path ~* '^/my';
path
----
(0 rows)

backup=> select path from foo where path ~* '/my';
path
----
/My
(1 row)

backup=> select path from foo where path ~* '/mY';
path
----
/My
(1 row)

backup=> select path from foo where path ~* '^/mY';
path
----
(0 rows)


Why e.g. does the statement "select path from foo where path ~* '^/my';"
not return the only entry "/My"? Can someone explain this?
--
Regards, martin@unix-ag.org


pgsql-general by date:

Previous
From: "Mitch Vincent"
Date:
Subject: varchar => int
Next
From: Peter Eisentraut
Date:
Subject: Re: Setting logfile location with pg_ctl and postgres.conf