Re: perlsub
От | Jeff Eckermann |
---|---|
Тема | Re: perlsub |
Дата | |
Msg-id | 20031006141701.61967.qmail@web20808.mail.yahoo.com обсуждение исходный текст |
Ответ на | Re: perlsub (Nabil Sayegh <postgresql@e-trolley.de>) |
Ответы |
Re: perlsub
|
Список | pgsql-novice |
(sound of dusting off of perl) Capturing using $1 etc definitely does work in pl/perl functions: I have used that plenty. Strictly speaking, backreferences in search-and-replace are signified by \1, \2 etc (not $1, $2). In the body of a PostgreSQL function those backslashes would need to be escaped: my preference is to double them (\\1, \\2). This does not seem to relate to your example though. Arbitrary search-and-replace works fine for me, in a simple case: create function s(text, text, text) returns text as ' $_[0] =~ s/$_[1]/$_[2]/; return $_[0]; ' language 'plperl'; Perhaps if you could post a "real" example, you might get more useful help. --- Nabil Sayegh <postgresql@e-trolley.de> wrote: > Thanks for your answer. > > The snippet was just an example. > What I really want(ed) to do was arbitrary regex > search/replace. > > Martin Lange wrote: > > > What I understand: You want to split some data > into a pair of key > > and value. > > > > So, just do that: > > > > ($key, $val) = split(/=/, $data); > > > > HTH. > > -- > e-Trolley Sayegh & John, Nabil Sayegh > Tel.: 0700 etrolley /// 0700 38765539 > Fax.: +49 69 8299381-8 > PGP : http://www.e-trolley.de > > > ---------------------------(end of > broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose > an index scan if your > joining column's datatypes do not match __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
В списке pgsql-novice по дате отправления: