Re: [SQL] Negative lookbehind assertions in regexs
I'd like a regex that matches 'CD' but not 'ABCD' in any part of the regex. From: "Bruno Wolff III" <[EMAIL PROTECTED]> Something like: (^.?CD)|([^B]CD)|([^A]BCD) Thanks to Bruno, and to Dawid who replied offline. The above does the job nicely. Any plans for a Perl Compatible Regular Expression operator? http://www.pcre.org/ Or are two regex operators enough? Julian ---(end of broadcast)--- TIP 6: explain analyze is your friend
Re: [SQL] Negative lookbehind assertions in regexs
On Sat, Sep 03, 2005 at 03:59:18PM +0100, Julian Scarfe wrote: > Any plans for a Perl Compatible Regular Expression operator? > http://www.pcre.org/ Why have Perl-Compatible things when you can have Perl itself? Just use plperl. > Or are two regex operators enough? Only two? We have not only our own code, but also Perl's engine, Python's, Tcl's, and PHP's, available through the PLs. That's more than enough, I'd say. -- Alvaro Herrera -- Valdivia, Chile Architect, www.EnterpriseDB.com "I call it GNU/Linux. Except the GNU/ is silent." (Ben Reiter) ---(end of broadcast)--- TIP 6: explain analyze is your friend
Re: [SQL] Negative lookbehind assertions in regexs
On 9/3/05, Julian Scarfe <[EMAIL PROTECTED]> wrote: >> I'd like a regex that matches 'CD' but not 'ABCD' in any part of the>> regex.From: "Bruno Wolff III" <[EMAIL PROTECTED]>> Something like: > (^.?CD)|([^B]CD)|([^A]BCD)Thanks to Bruno, and to Dawid who replied offline. The above does the jobnicely. 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, '(? 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