Regular expressions and arrays and ANY() question - Mailing list pgsql-general

From webb.sprague@gmail.com
Subject Regular expressions and arrays and ANY() question
Date
Msg-id 1169331020.695761.100710@11g2000cwr.googlegroups.com
Whole thread Raw
Responses Re: Regular expressions and arrays and ANY() question
List pgsql-general
I am trying to figure out how to use a regex and an ANY(), without any
luck, to determine if at least one element of an array (on the right)
matches the given constant pattern (on the left).

 I think the problem is because the pattern expects to be on the right
side with the target on the left, but I want to do it reversed.  (ie I
want 'Corvalli%' like 'Corvallis', but for postgres the only thing is
'Corvallis' like 'Corvalli%').  Has anybody worked around this before?

See below for code. TIA.  Feel free to email me directly.

or_gis=# select  *   from quads_w_cities where 'Corvallis' = any
(cities); -- this works like I want
 ohiocode |               cities
----------+-------------------------------------
 44123e2  | {Albany,Corvallis,Tangent,Estacada}
 44123e3  | {Corvallis,Philomath}
(2 rows)


or_gis=# select  *   from quads_w_cities where 'corv.*' ~  any
(cities);  -- I want this to give me something just like the above
 ohiocode | cities
----------+--------
(0 rows)

or_gis=# select  *   from quads_w_cities where 'corv.*' ~~  any
(cities); -- etc...
 ohiocode | cities
----------+--------
(0 rows)

or_gis=# select  *   from quads_w_cities where 'corv.*' ~*  any
(cities);
 ohiocode | cities
----------+--------
(0 rows)

or_gis=# select  *   from quads_w_cities where 'Corv.*' ~*  any
(cities);
 ohiocode | cities
----------+--------
(0 rows)

or_gis=# select  *   from quads_w_cities where '.*Corv.*' ~*  any
(cities);
 ohiocode | cities
----------+--------
(0 rows)


pgsql-general by date:

Previous
From: "Shoaib Mir"
Date:
Subject: Re: Who is Slony Master/Slave + general questions.
Next
From: "Michael Nolan"
Date:
Subject: Re: More grist for the PostgreSQL vs MySQL mill