Re: regexp searching in arrays not working? - Mailing list pgsql-general

From Rhys Stewart
Subject Re: regexp searching in arrays not working?
Date
Msg-id 189966030706200525h47467332i43852a00d2c270ed@mail.gmail.com
Whole thread Raw
In response to Re: regexp searching in arrays not working?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
thats cool,

thanks.

2007/6/19, Tom Lane <tgl@sss.pgh.pa.us>:
"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 by date:

Previous
From: Enrico Sirola
Date:
Subject: copying indexes and f.keys from a template table
Next
From: Francisco Reyes
Date:
Subject: Re: pg_restore out of memory