Re: regexp searching in arrays not working?

From: "Rhys Stewart" <rhys(dot)stewart(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: regexp searching in arrays not working?
Date: 2007-06-20 12:25:03
Message-ID: 189966030706200525h47467332i43852a00d2c270ed@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

thats cool,

thanks.

2007/6/19, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>
> "Rhys Stewart" <rhys(dot)stewart(at)gmail(dot)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
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martin Langhoff 2007-06-20 12:51:59 LC_CTYPE and matching accented chars
Previous Message Enrico Sirola 2007-06-20 10:57:55 copying indexes and f.keys from a template table