REGEXP: returning match?

Started by Jean-Christian Imbeaultover 23 years ago2 messagesgeneral
Jump to latest
#1Jean-Christian Imbeault
jc@mega-bucks.co.jp

Is there a simple way to get psql to return the part that match a query
containing a regexp?

Jc

#2Jeff Eckermann
jeff_eckermann@yahoo.com
In reply to: Jean-Christian Imbeault (#1)
Re: REGEXP: returning match?
--- Jean-Christian Imbeault <jc@mega-bucks.co.jp>
wrote:

Is there a simple way to get psql to return the part
that match a query
containing a regexp?

CREATE FUNCTION str_capture(text, text) RETURNS text
AS '
$_[0] =~ m/($_[1])/;
return $1;
' LANGUAGE 'plperl';

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com