use of / in ~ vs. ~*

Started by Hannu Krosingover 25 years ago4 messages
#1Hannu Krosing
hannu@tm.ee

Can anyone explain why I must make / a character class
in case-insensitive query in order to match / ?

and then why does it work in plain ~ ?

hannu=> select * from item where path ~* '^/a';
path
------
/a/b/c
/a/b/d
/a/d/d
/aa/d
/a/b
/a/c
/a/d
(7 rows)

hannu=> select * from item where path ~ '^/a';
path
------
/a/b/c
/a/b/d
/a/d/d
/aa/d
/a/b
/a/c
/a/d
(7 rows)

hannu=> select * from item where path ~* '^/A';
path
----
(0 rows)

hannu=> select * from item where path ~* '^[/]A';
path
------
/a/b/c
/a/b/d
/a/d/d
/aa/d
/a/b
/a/c
/a/d
(7 rows)

------------
Hannu

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Hannu Krosing (#1)
Re: use of / in ~ vs. ~*

Hannu Krosing <hannu@tm.ee> writes:

Can anyone explain why I must make / a character class
in case-insensitive query in order to match / ?

What LOCALE are you using? There was a thread about strange ordering
rules confusing the LIKE/regexp optimizer recently ...

regards, tom lane

#3Hannu Krosing
hannu@tm.ee
In reply to: Hannu Krosing (#1)
Re: use of / in ~ vs. ~*

Tom Lane wrote:

Hannu Krosing <hannu@tm.ee> writes:

Can anyone explain why I must make / a character class
in case-insensitive query in order to match / ?

What LOCALE are you using? There was a thread about strange ordering
rules confusing the LIKE/regexp optimizer recently ...

I think I'm using the default locale (this is just straight install on
Linux from RPM-s)

Is there any way to find out the locale used from within the running
system ?

The most obvious way ( select locale(); ) does not work .

-----------
Hannu

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Hannu Krosing (#3)
Re: use of / in ~ vs. ~*

Hannu Krosing writes:

I think I'm using the default locale (this is just straight install on
Linux from RPM-s)

Is there any way to find out the locale used from within the running
system ?

The locale the postmaster uses is whatever was set in its environment,
i.e., LC_ALL, etc.

--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/