Re: regexp searching in arrays not working?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: regexp searching in arrays not working?
Дата
Msg-id 18766.1182296162@sss.pgh.pa.us
обсуждение исходный текст
Ответ на regexp searching in arrays not working?  ("Rhys Stewart" <rhys.stewart@gmail.com>)
Ответы Re: regexp searching in arrays not working?  ("Rhys Stewart" <rhys.stewart@gmail.com>)
Re: regexp searching in arrays not working?  (David Fetter <david@fetter.org>)
Список pgsql-general
"Rhys Stewart" <rhys.stewart@gmail.com> writes:
> Is regex searching not functioning (as i expect it to?)

~ expects the pattern on the right, not the left.  So it's taking your
array entries as patterns, which don't match the data 'Trans'.

Since there's no "(array) ANY op scalar" syntax, the only way to get
this to work is to make a reverse-pattern-match operator that takes
the pattern on the left.  You can glue one together from spare parts
easily enough:

regression=# create function reverse_regex(text,text) returns bool as
regression-# 'select $2 ~ $1' language sql immutable strict;
CREATE FUNCTION
regression=# create operator ~~~ (procedure = reverse_regex,
regression(# leftarg = text, rightarg = text);
CREATE OPERATOR

but I'm not sure what the performance will be like with a SQL function
in there...

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: "Rhys Stewart"
Дата:
Сообщение: regexp searching in arrays not working?
Следующее
От: David Gardner
Дата:
Сообщение: Re: Excell