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) ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])