Thread: use of / in ~ vs. ~*

use of / in ~ vs. ~*

From
Hannu Krosing
Date:
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


Re: use of / in ~ vs. ~*

From
Tom Lane
Date:
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


Re: use of / in ~ vs. ~*

From
Hannu Krosing
Date:
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


Re: use of / in ~ vs. ~*

From
Peter Eisentraut
Date:
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/