Re: Negative lookbehind assertions in regexs
От | Dawid Kuroczko |
---|---|
Тема | Re: Negative lookbehind assertions in regexs |
Дата | |
Msg-id | 758d5e7f050903101842197d38@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Negative lookbehind assertions in regexs ("Julian Scarfe" <julian@avbrief.com>) |
Список | pgsql-sql |
On 9/3/05, Julian Scarfe <julian@avbrief.com> wrote:
I intended to post Cc: to the list, but somehow I didn't (blame it on computers,
I just assumed Cc is set ;)).
Anyway, when perl_re's are craved for, once could use PLperl for this:
CREATE OR REPLACE FUNCTION perl_re(v text, r text)
RETURNS boolean LANGUAGE plperl STRICT IMMUTABLE AS $$
my ($val, $re) = @_;
return ($val =~ m{$re}) ? 't' : 'f';
$$;
...though it should be noted that queries WHERE perl_re(col, '(?<!AB)CD')
will not use indexes. (unless there are functional indexes on that function,
but then you would need one index for each regex used).
Regards,
Dawid
>> I'd like a regex that matches 'CD' but not 'ABCD' in any part of the
>> regex.
From: "Bruno Wolff III" <bruno@wolff.to>
> Something like:
> (^.?CD)|([^B]CD)|([^A]BCD)
Thanks to Bruno, and to Dawid who replied offline. The above does the job
nicely.
I intended to post Cc: to the list, but somehow I didn't (blame it on computers,
I just assumed Cc is set ;)).
Anyway, when perl_re's are craved for, once could use PLperl for this:
CREATE OR REPLACE FUNCTION perl_re(v text, r text)
RETURNS boolean LANGUAGE plperl STRICT IMMUTABLE AS $$
my ($val, $re) = @_;
return ($val =~ m{$re}) ? 't' : 'f';
$$;
...though it should be noted that queries WHERE perl_re(col, '(?<!AB)CD')
will not use indexes. (unless there are functional indexes on that function,
but then you would need one index for each regex used).
Regards,
Dawid
В списке pgsql-sql по дате отправления: