Re: Inside the Regex Engine

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Inside the Regex Engine
Дата
Msg-id 20031203033842.GB4813@dcc.uchile.cl
обсуждение исходный текст
Ответ на Inside the Regex Engine  (david@fetter.org (David Fetter))
Список pgsql-hackers
On Tue, Dec 02, 2003 at 07:52:57PM -0600, David Fetter wrote:

> As a perl weenie, I'm used to being able to do things with regexes
> like
> 
> $text =~ s/(foo|bar|baz)/NO UNIX WEENIES HERE/;
> $got_it = $1;
> 
> While PL/Perl is great, it's not available everywhere, and I'd like to
> be able to grab atoms from a regex match in, say, a SELECT.  Is there
> some way to get access to them?

Huh, the best I am able to do is

alvh=> select substring('bazfoo fubar', 'fu(foo|bar)');substring
-----------bar
(1 fila)

The choice of the name for the function seems weird to me.  Also note
that you are able to use only one set of parenthesis (i.e. the first
gets picked up, the rest is ignored).

If you need to be able to extract further things, there's a tip in the
docuemntation that reads

"If you have pattern matching needs that go beyond this, consider
writing a user-defined function in Perl or Tcl."

It does not appear to be that difficult to add the functionality needed
to extract random atoms, but there's some hacking involved.

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Cuando no hay humildad las personas se degradan" (A. Christie)


В списке pgsql-hackers по дате отправления:

Предыдущее
От: greg@turnstep.com
Дата:
Сообщение: Re: ALTER SEQUENCE enchancement
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Inside the Regex Engine