using regexp_matches and array manipulation - Mailing list pgsql-general

From Bret Schuhmacher
Subject using regexp_matches and array manipulation
Date
Msg-id 48813D94.9060409@welcometolazyhill.com
Whole thread Raw
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Can anyone give me an example of how to use regexp_matches and use the
captured values?

For instance, if I have a delimited string "a,b,c" and I want to put
each letter into a variable so I can subsequently use those variables in
an insert statement, how would I do that?  I know regexp_matches returns
a text array, but how do I assign the value to an array and then access
those values?

leaselog=# select regexp_matches('a,b,c','(.*),(.*),(.*)');

~ regexp_matches
- ----------------
~ {a,b,c}
(1 row)


I've tried select into, but that just created a table and didn't put the
values into an array variable.
leaselog=# select regexp_matches('a,b,c','(.*),(.*),(.*)') into foo;


Thanks in advance!


Rgds,

Bret
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)

iD8DBQFIgT2T/PgQIGRJuUcRAvMGAJ9VRNfc5ZZsFtS2LG8VJgPNNnL1wwCfewlf
Jih6ReqSTj6Pp9Ya3B2uMn8=
=HbPn
-----END PGP SIGNATURE-----


pgsql-general by date:

Previous
From: Francisco Reyes
Date:
Subject: Re: Backup/Restore of single table in multi TB database
Next
From: Tom Lane
Date:
Subject: Re: UPDATE runs slow in a transaction