Regular expressions and arrays and ANY() question
От | webb.sprague@gmail.com |
---|---|
Тема | Regular expressions and arrays and ANY() question |
Дата | |
Msg-id | 1169331020.695761.100710@11g2000cwr.googlegroups.com обсуждение исходный текст |
Ответы |
Re: Regular expressions and arrays and ANY() question
|
Список | 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 по дате отправления: